How can I directly insert JSON using Mongoose/MongoDB?

Go To StackoverFlow.com

1

It seems a bit convoluted to manually define a schema when I'm dealing with JSON all the time. Is there a way to convert JSON into BSON thereby relieving the developer of the need to manually define schemas each time?

2012-04-04 22:56
by deltanovember
Are you saying you just want to accept any sort of json data without having a model - Randall Hunt 2012-04-04 23:01
I'm saying that I would like the model to be automatically derived from the JSO - deltanovember 2012-04-04 23:25
The only thing out there in JS is this, and it's really just a proof of concept, not a reliable library. https://gist.github.com/107051 - Incognito 2012-04-04 23:33
My understanding is that mongoose was specifically developed for modelling. If you don't want to do modelling, you should use a mongodb driver/wrapper that doesn't require it, such as mongoskin or mongolia - Ivo Bosticky 2012-04-05 04:38
Simply update your mongoose schema to insert an object images: {type: Object}Donald Derek 2013-09-15 01:57


-1

There is a tool mongoimport to do this

http://www.mongodb.org/display/DOCS/Import+Export+Tools

2012-04-22 22:38
by deltanovember
How did you solve it ? please can you explain - Back Packer 2017-06-08 10:21


2

Have you looked at node-mongodb-native[1]? It sounds like it might be a better fit for your needs since it doesn't require a predefined schema.

[1] https://github.com/christkv/node-mongodb-native

2012-04-05 15:15
by mstearn
Ads