Cursor Methods: Min

Limiting a minimum value for a query in the collection.

🪶 The min method defines a minimum value for the query, which must not be less than the specific limit.

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(
  • )
  • ;
    5merlin
  • .connect(
  • "USER-DATABASE"
  • )
  • ;
    6
  • var
  • userModel = merlin
  • .model(
  • "User", <userSchema>
  • )
  • ;
    7
    8
  • //cursor.min(<object>);
  • 9userModel
  • .find(
  • {
  • age:
  • 23
  • }
  • )
  • 10
  • .min(
  • {
  • age:
  • 12
  • }
  • )
  • 11
  • .then(
  • e =>
  • {
  • 12   console
  • .log(
  • e
  • )
  • ;
    13  
  • //returns all documents where the age is equal to 23 and greater than 12
  • 14
  • }
  • )