Can I use mongoimport's upsert to append to an array?

185 views
Skip to first unread message

Román

unread,
Sep 9, 2011, 10:48:52 AM9/9/11
to mongodb-user
Hi everyone.

I have a collection with data structured as:

{ _id : <id>, label : "numeric_id", : lastDataForLabel : { <an
object> }, allDataForLabel : [ <some objects> ] }

The data (potentially lots of it) comes from another component and I'd
like to load it to mongo using mongoimport, for performance reasons.
Each update will have a new lastDataForLabel but I'd like to add that
to the array as well.

Is it possible to do that? I'd use $push, but the documentation for
mongoimport says update modifiers are not allowed.

Also: do I need to use mongoimport? Maybe it's not as fast as I think,
but I'd need a boss-convincing argument for this ;)

Thanks,
Román.

Scott Hernandez

unread,
Sep 9, 2011, 11:30:50 AM9/9/11
to mongod...@googlegroups.com
You should write your own script. Mongoimport is just a small program
which uses the same protocol as all other drivers and languages; there
is nothing magic about it nor does it provide any serious performance
that you can't achieve with your own program.

You may also find that importing with multiple threads/processes will
reduce the time to do the import. Most of the time the client is the
gating factor in loading data.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages