These are chat archives for Automattic/mongoose

4th
Oct 2017
KARTHIKEYAN A
@karthikeyana__twitter
Oct 04 2017 04:00
@vladotesanovic its working
Abdul-Samii Ajala Olalekan
@jalasem
Oct 04 2017 16:18

Please who can suggest how I can query this in mongodb
I have a user doc like this;

{
      fullname: "",
      profilePic: "http://gravatar.com/kjnjksnjskjsnsnoiino"
      following: [user1id, user2id, user33id, user67id],
      ...
}

I have my sample post doc like this

{
      body: "lorem ispsum... ",
      author_id: "bjj12334344",
      createdOn: someTimeStamp,
      ...
}

what query do I write with mongoose or mongo db to fetch post from my the users a user is following and such that a post is fetched along with the fullname and profilePic of the author.

in a way that the result will look like this

    [
       {  body: "lorem ipsum...",  createdOn: timeStamp,
           author: {
                 name: "",
                 profilePic: "",
       },
       {  body: "lorem ipsum...",  createdOn: timeStamp,
           author: {
                 name: "",
                 profilePic: "",
       },
       {  body: "lorem ipsum...",  createdOn: timeStamp,
           author: {
                 name: "",
                 profilePic: "",
       }
    ]
Tom Beute
@beuteiful_twitter
Oct 04 2017 19:33
anyone here know if its possible to have populate return an exact value instead of an object containing the value?