hello I am a mongoDB noob, And I wanted to retrieve a list of comments on a post:
{
id:0,
ref:0,
type: 'image',
date: null,
title: 'this is my title',
comments:[
{
user : 'myUser',
text : 'text'
},
{
user : 'myUser2',
text : 'text2'
}
}
how can I query only the comments array of a post?
I dont want to retrieve the post with the comments inside it, but only the comments without anything else?
here is my first attempt with jongo :
Post.posts().find("{ref : #}", ref).projection("{comments : 1}").as(Post.Comment.class)
this doesn't work :/, I waas thinking about casting the comments array to a Comment type. and using the projection to only retrieve the comments part...