Sign in
Log inSign up

mongodb aggegation- project key in root to inside an object

Siraj abbas's photo
Siraj abbas
·Aug 4, 2017

Hi I have the following requirement.Somebody plz help me.

I am doing a mongodb aggregate operation for which my final data looks like below

{
 "data":{
},
  "subdata":[{}]
}

For some reason I would like to get the final result as

{
  "data":{
    "subdata":[{}]
  }
}

I tried several ways.It is not working as I expected.

PS:I am not using mongoose.

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct