Model Methods: Estimated Document Count
Estimating the number of documents in a collection.
🪶 The estimatedDocumentCount method is used to estimate the number of documents in a collection.
1 import MerlinDB, { Schema} from "@chrisaxxwell/merlin-db";2 //Or if you are using 'merlindb.max.js' just call 'new MerlinDB()'; 3 4 const merlin = new MerlinDB( ) ;5 merlin.connect( "USER-DATABASE") ; 6 7 const UserSchema = Schema( { 8 name: String , 9 age: Number 10 } ) ; 11 12 var userModel = merlin.model( "User", UserSchema) ;13 14 //userModel.estimatedDocumentCount(); 15 userModel.estimatedDocumentCount( ) 16 .then( e => console.log( e) ) ; 17 //returns: 20