How to query a nested document in mongo?

Is it acceptable to store json api responses directly into mongoDB, as your main document structure and work from that? Is 45kb per document workable?

  • I am looking to develop a simple webapp, that really relies on 3rd party API's and I can't see why I can't just query the REST endpoint, store the returning JSON into MongoDB, and then just throw that to a client-side library e.g. knockout-js. Is this one of the purpose-built mechanisms for mongo's conception?

  • Answer:

    After attending a presentation done by Ross Lawley, I think the situation is thus: 45kb is a workable document file size, and that with the latest aggregation functions implemented, then given the structure of the REST response,  this approach is totally feasible

Sky Viker-Rumsey at Quora Visit the source

Was this solution helpful to you?

Other answers

Hi,You are on correct track.MongoDB actually stores the documents in JSON itself. So, whatever JSON you have can go directly into Mongo document. Just make sure you serialize them.Blog : https://www.mongodb.com/json-and-bsonAbout your second question —The maximum document size that is allowed in Mongo is 16 MB. So, if you are storing about 45 KB per document then it is totally fine. But, it is recommended that your document size should be minimum, so that you have a proper schema. That depends on your usecase.Read : https://docs.mongodb.com/manual/reference/limits/Good luck for your webapp! :)_RB

Rohit Badwaik

Interesting you ask that because we are doing that too, We are logging every api request and reply to the MongoDb, it’s working great with much bigger doc too (1MB). Do keep in mind the record restrictions to avoid API outage - keys cannot contain dots and some strange characters might be rejected by the DB.

Avi Kapuya

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.