Sign In Register

How can we help you today?

Start a new topic
Answered

Can I save multiple documents at once?

Once in a big while, I need to save 10000 documents into a collection at once, and move that 10000 documents to another collection when the time comes. The thing is it takes 9 minutes to do so. Reasonable but it's still pretty long.


I googled a bit and found out that MongoDB can do bulk insert, but I can't find that function in Cloud Code.


Is there any better way to do bulk insert and move to another collection than save/remove them all individually?


Best Answer

Hi Nipitpon,


Currently we don't expose MongoDB bulk operations to javascript. There is a method for doing this using a python script which you can read about in a forum post here. From the sounds of it you are already doing something similar ? At the moment this is the most efficient way to do it. If you have any more questions just let me know.


Thanks,

Liam

1 Comment

Answer

Hi Nipitpon,


Currently we don't expose MongoDB bulk operations to javascript. There is a method for doing this using a python script which you can read about in a forum post here. From the sounds of it you are already doing something similar ? At the moment this is the most efficient way to do it. If you have any more questions just let me know.


Thanks,

Liam

Login to post a comment