mongoDB array pagination

后端 未结 1 1902
难免孤独
难免孤独 2020-12-12 07:36

I have a comment collection with Comment Text in array with its Metadata. I like to the pagination in the Comment Text Array. The pagination should allow me to get the \"pr

相关标签:
1条回答
  • 2020-12-12 08:14

    You can do this with $slice: http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements

    There's also a js test example of slice here, with several examples: https://github.com/mongodb/mongo/blob/master/jstests/slice1.js

    So, findOne, combined with $slice, is probably the way to go.

    Without more info about the language you're using, I think that's the deepest I can go.

    0 讨论(0)
提交回复
热议问题