I would like to determine mongodb collection size in my java spring application. I know that reactive rective Mongo Template has a count()
method what does that, however it needs a query param.
So my solution is:
public Mono<Long> collectionSize(){
Criteria criteria = Criteria.where("_id").exists(true);
return this.reactiveMongoTemplate.count(Query.query(criteria),MY_COLLECTION_NAME);
}
However I dont like this solution, because I have to use a captain obvious criteria.
Is there any better solution for this problem?
Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…