Can update with $inc be used to decrement value?

2,763 views
Skip to first unread message

D. Smith

unread,
Nov 26, 2010, 11:31:31 AM11/26/10
to mongodb-user
Just want to make sure that $inc with negative value will decrement
the value.
db.people.update( { name:"Joe" }, { $inc: { n : -1 } } );
Will this work?

Andreas Jung

unread,
Nov 26, 2010, 11:33:41 AM11/26/10
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can try that out easily yourself from the Mongo shell :)

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJM7+FlAAoJEADcfz7u4AZjjKcLwMwzLWTeWBQ2w0bPPMmJoc79
Qy7vsiUVT15A2outnwoIWip83J/sWKqFnw7GrBhm8gfmWAV5jHmQEzUR3t9JuFmZ
9rYtObadLa6VEOc6dLkwQKsEXY5uuNQu7yhfFzIswa3qrivvltxeq6li/4o6FVvd
8jpuAHDepkuDVINKRhusPB/N95CJF+nwyS0MsH3UzPnnjTEWmIp9d17i89yny4Rz
McyJQVbiDZLX07YER6EpHS8IqWlKc9tXI8ZPgXHIUsRAOdpPyRG9OOp42Kv0br0r
taiIMqSZdD2z54NaMXeULMgpVNOqQPxsVuR+VItNI82s3U1HqAPWBa/aktk/p2Gu
w5ejJDHHO6SUHJef6c3J0tOb2nhV4siZild+6uYYXHAqZhBUcqHsQqmiYiEsWhHp
+WokqPDThziOJXtcdpRHrqGqYpPpVFRQxGDJw44XDpPLQgiLGfRXZwEPFJBBGrpi
KC+leA+g+ShQMV/CWcJ3ilBj1eEM0p4=
=DwSl
-----END PGP SIGNATURE-----

lists.vcf

Scott Hernandez

unread,
Nov 26, 2010, 11:38:45 AM11/26/10
to mongod...@googlegroups.com
Yes, but always test :)

> --
> 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