0

I am storing post comments in a post, and the problem I am facing right now is that I cannot use limit with skip on an array of a document, since the users can post as many comments as they want, the array will be huge, So i wanted to paginate the comments.

is there a way to accomplish this?

is it possible to only retrieve like 10 comments per call?

thanks!

{
  id:0,
  ref:0,
  type: 'image',
  date: null,
  title: 'this is my title',
  comments:[
      {
        user : 'myUser',
        text : 'text'
      },
      {
        user : 'myUser2',
        text : 'text2'
      }
}

1 Answer 1

1

Found the solution: in projections just do :

projection("{comments : {$slice:[#,#]}}",start,size)

Sign up to request clarification or add additional context in comments.

2 Comments

what was the exact syntax did you use there?
Were you able to get a solution and how did it work? can you please share it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.