I have a really deep-nested JSON object generated by aggregation query, but I want to convert all the object ids to string format. Tried $toString in $addFields and $project. Since the object is nested and contains an array of objects with object id. It's difficult to do using this. Is there any other way by which I can convert all object ids to string in MongoDB during querying?

  • Is unwind -> modify -> group an option?
    – Joe
    Aug 19 at 18:08
  • Nope @Joe this was not necessary. Please see the answer below Aug 25 at 9:05

I have used the $addFields and $project operators to solve this. Although it took time. But the issue is resolved.




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.