bulk insert

11919 views
Skip to first unread message

Алексей Иванов

unread,
Jul 22, 2011, 9:47:50 AM7/22/11
to mongoo...@googlegroups.com
Hello!
If there any way to insert huge amount of objects in one collection faster than just call save for each? I couldn't find any information about it.

Thanks in advance,
    Alexey.

Aaron Heckmann

unread,
Jul 22, 2011, 10:36:34 AM7/22/11
to mongoo...@googlegroups.com
not really. Model.create(doc1 [, docN], callback)  sort of helps here but its still calling model.save for you on each one.

If by "faster" you mean "bypass all mongoose hooks and validation" then you could drop down to the native driver and use it directly:

Movie.collection.insert(docs, options, callback)

--
Aaron


Алексей Иванов

unread,
Jul 25, 2011, 12:18:53 PM7/25/11
to mongoo...@googlegroups.com
Thanks, Aaron.
It really helps. Now inserting is fast.

Alexey

Raitucarp

unread,
Apr 3, 2013, 1:24:25 PM4/3/13
to mongoo...@googlegroups.com
Can I use it for upsert?

Aaron Heckmann

unread,
Apr 3, 2013, 5:36:50 PM4/3/13
to mongoo...@googlegroups.com
Is "it" model.create or model.collection.insert?

model.create() does not currenlty support options like upsert
model.collection.insert() does


--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron


Reply all
Reply to author
Forward
0 new messages