[DOCS-1588] $unset invalid : "manual/reference/operator/unset.txt" Created: 09/Jun/13  Updated: 03/Nov/17  Resolved: 10/Jun/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: auto Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 10.04 / MongoDB 2.4.4 (10Gen APT repository version)

Location: http://docs.mongodb.org/manual/reference/operator/unset/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Referrer: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
Screen Resolution: 1920 x 1080
repo: docs
source: reference/operator/unset


Participants:
Days since reply: 10 years, 36 weeks, 2 days ago

 Description   

Am I crazy? I'm losing it for sure!

Issuing this command:

db.mycollection.update(

{ thefield: 'avalue' }

, { $unset:

{ unsetfield: 1 }

})

Causes this error: Invalid modifier $unset

Reporter: Joseph T
E-mail: me@josepht.com



 Comments   
Comment by Joseph Taylor [ 11/Jun/13 ]

Edit: oops! Even though the mongod version was 2.4.4, I never restarted the mongod process itself... the database version was 1.2.2. Solved!

--------
I did exactly as you, and received the same error as previously posted. I don't have much context, other than the following:

MongoDB Shell Version: 2.4.4
Debian Installation (Ubuntu 10.04): mongodb-10gen_2.4.4_amd64.deb

Output from mongod.log:

Mon Jun 10 20:07:47 insert test.foo 181ms
Mon Jun 10 20:08:41 update test.foo query:

{ x: "foo" }

exception userassert:Invalid modifier specified $unset 0ms
Mon Jun 10 20:08:52 test.foo Caught Assertion update, continuing
Mon Jun 10 20:08:52 update test.foo query:

{ x: "foo" }

exception userassert:Invalid modifier specified $unset 0ms

Comment by Sam Kleinman (Inactive) [ 10/Jun/13 ]

I wasn't able to reproduce this issue:

PRIMARY> db.foo.insert( { x: 'foo', y: 'bar' })
PRIMARY> db.foo.find( { x: 'foo' })
{ "_id" : ObjectId("51b61c3f1bd174359c4532f6"), "x" : "foo", "y" : "bar" }
PRIMARY> db.foo.update( {x: 'foo'}, { $unset: { y: 'bar' } })
PRIMARY> db.foo.find( { x: 'foo' })
{ "_id" : ObjectId("51b61c3f1bd174359c4532f6"), "x" : "foo" }

as well as the following:

PRIMARY> db.foo.insert({ x: 'foo', y: 'bar' })
PRIMARY> db.foo.find()
{ "_id" : ObjectId("51b61d1c1bd174359c4532f8"), "x" : "foo", "y" : "bar" }
PRIMARY> db.foo.update({x: 'foo'}, { $unset: { y: 1 } } )
PRIMARY> db.foo.find()
{ "_id" : ObjectId("51b61d1c1bd174359c4532f8"), "x" : "foo" }
PRIMARY> 

Please provide additional context to help us diagnose the documentation error or lack of clarity. Also consider asking this question of Stack Overflow (http://stackoverflow.com/questions/tagged/mongodb) or our user group (http://groups.google.com/group/mongodb-user).

Regards,
sam

Generated at Thu Feb 08 07:41:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.