Yang Y
unread,May 4, 2011, 1:11:22 PM5/4/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
we want to use mongoimport to import into our mongodb,
the import process ***updates*** existing entries with the same key.
for example , in db, we have
{ name:"joe", salary:"100"}
and the new import data contains
{name:"joe", salary:"101"}
we want the old data to be update/overwritten, instead of adding a
second entry for {name:"joe"}
we could do this by setting {_id: } to be the same value as name:
field.
but the problem is that the input data we have come from an upstream
job, and it's bad to expose the internal logic of mongo to the output
of that stage; instead we know that the "name" will always be the
unique field.
so in this case, how can we tell mongo to use "name" as the unique
field, instead of "_id" ?? (I tried creating an unique index on
"name", but it does not allow overwrite, but just fails on save()
with the same key )
Thanks a lot
Yang