Cursor Methods: Skip

Skipping a number of documents in a collection in the database in MerlinDB.

🪶 The skip method is used to skip a specified number of documents in a query.

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.skip(<number>);
  • 9userModel
  • .find(
  • {
  • name:
  • "Sam"
  • }
  • )
  • 10
  • .skip(
  • 2
  • )
  • 11
  • .then(
  • e =>
  • {
  • 12  
  • //Returns all documents whose name is 'Sam' from the second document onwards
  • 13
  • }
  • )