Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
List level pagination in mongo DB

Mongo document structure as follows:

{ 
    "dictID" : "dd001", 
    "dictVersion" : 1, 
    "addMeasures" : 
    [ 
        { 
            "measureId" : "f229ba18", 
            "userId" : "3966C3DD", 
            "created" : "2017-01-07T05:47:22.512Z" 
        }, { 
            "measureId" : "0b701469", 
            "userId" : "3966C3DD", 
            "created" : "2017-01-07T05:47:35.193Z" 
        } , { 
            "measureId" : "f229ba1823", 
            "userId" : "3966C3DD", 
            "created" : "2017-01-07T05:47:22.512Z" 
        }, { 
            "measureId" : "0b7014699", 
            "userId" : "3966C3DD", 
            "created" : "2017-01-07T05:47:35.193Z" 
        } 
    ]
}

I need a pagination for single document on array list

Ex. In my document "addMeasures" has multiple maps, I want pagination on it so that it should give me part "addMeasures" like limit 1,2.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

use the $slice operator

db.collection.find({}, {dictId: 1, dictVersion: 1, addMeasures: {$slice: [0, 2]}})

returns:

{
   "_id":ObjectId("5890572371cbc5eae2c9535b"),
   "dictVersion":1,
   "addMeasures":[
      {
         "measureId":"f229ba18",
         "userId":"3966C3DD",
         "created":"2017-01-07T05:47:22.512Z"
      },
      {
         "measureId":"0b701469",
         "userId":"3966C3DD",
         "created":"2017-01-07T05:47:35.193Z"
      }
   ]
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!