> --
> 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.
>
>
You can not change the _id of a document. It's immutable.
- -aj
- --
ZOPYX Limited | zopyx group
Charlottenstr. 37/1 | The full-service network for Zope & Plone
D-72070 T�bingen | Produce & Publish
www.zopyx.com | www.produce-and-publish.com
- ------------------------------------------------------------------------
E-Publishing, Python, Zope & Plone development, Consulting
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJOrBjkAAoJEADcfz7u4AZj1/wLvi5OcQ3EXqp0udFwX/RS82Fx
aA5SGdY8pJnvMAYrPu57SUChSA+qnYEYANKLk3NB9rilcMCWTt7pyaSb9n/NWsx3
3idDytuMJPLnaUvk5ahSHWyGpyvIaKDCyhrsn4dM+IVCtcl7yMEgVBrPjqSCMQrz
08+xgyp/hCW2LOQiI9oNWzGncu0gn6I6D48oLs6jVLb9Da8o1AAR6rCAkl5KZwU9
wIaw23HQsuQriCbk7cJHjtt0n/M+dRPFjhLlWd7zn3dbFcDiMHQN04pYQGL3Fy+h
QUovy/dQaXWE3AiSwibmPHTjEEuyHhHy9//hipRrjYmhB3bVVSIHwTDRa73rZS8x
VA2RDKavRGjzSL75F83L1COMczn2eCwmOvK6UUAtoQTClgKG6hmA1H29V2Jtq29l
nYZY3zfBCqoaLjSkYE0cKShKI1MpshWXpsw7U3kLh5Oz6tE8lQ/qb6h5NBnBVS91
8fNBWchzGPBZfgHrLtN5Onr8oOpmWqQ=
=j42v
-----END PGP SIGNATURE-----
Update w/upsert = update the doc if found, else insert a new document
(take the query, apply the updates and insert).
Are you just trying to find the document with the name:"xxx", and you
don't know the _id? It seems like your aim is at odds logically with
what you are trying to do.
If you are basically trying to change the _id field, which is
basically what your update statement looks like, then you should just
go through all the existing ones and do that (remove + insert
w/new-_id).
Here are some more docs which may help you to understand things a bit
better. http://www.mongodb.org/display/DOCS/Updating
mguserdev wrote:
>
> So, I need a way to do an upsert in mongodb in which if a NEW doc is
> inserted, the _id value of that new doc is a custom _id value that I
> get to define in the upsert command, not the auto-generated
> 4eabff2e493e3cf75aa54b74 value that mongodb is using by default.
>
What is the problem? Why don't you specify your custom _id
as part of the query clause *and* the update clauses?
- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJOrC/4AAoJEADcfz7u4AZjs6oLvi3+vE47pMiKYgxhe06ys8/6
g+QaqmQLSzMB+Vs200YCCce5tbMJmCw93f6dBOw6QYzHvzTegF1n3UO9ThFdMgmY
0ncZTdgedhZcPix7D8rgTLRO4out/8vXECSgHRxm+ZW5w+dm86fF6CnXXwaBjB+n
jU2kHA3SA4kmTfY9MhosRF9R+yXlyfmEBc3qfQ7nmSjgtQ6/X4elk+fmi9sXRb73
JwGYWGJ3r2Van4iRCI0PRfsDJj6B2MSI3ZbS1NSTpLzLmTkExvRiRtxQKo8oDPs3
e6nP1hgcZptvd/LKwNnl3JPPWvqpVhbY8TUPhlTW5oVuTiX4uzPdMYK5uNJMG31T
sj8wdb13HvP7ynmjpDKnG7oxN3j6y+6h/5U5BEP4Ok6XX+Ik14fRSMMBLQUstHDT
6THN5rE/QQZ2ofYleUAM/jBQqTGT1USa7cQ7gCPHv6olNsgXdHiVydhhsDXXTkTL
8VdvsJjsP5KYEbc7rTMJqxrdvd/wSrs=
=78F1
-----END PGP SIGNATURE-----