Issue Details (XML | Word | Printable)

Key: SERVER-134
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mathias Stearn
Reporter: Kristina Chodorow
Votes: 20
Watchers: 12
Operations

If you were logged in you would be able to see more operations.
Core Server

$unset (was: $unset and $rename)

Created: Jul 08 2009 10:55 AM UTC   Updated: Jan 05 2010 10:09 PM UTC
Return to search
Component/s: Updates
Affects Version/s: None
Fix Version/s: 1.3.0

Issue Links:
Related
 

Backport: No


 Description  « Hide
Right now, you can only do a $set on an update. It would be helpful to be able to delete or rename a field as well.

 All   Comments   Change History   git Commits      Sort Order: Ascending order - Click to sort in descending order
Wouter added a comment - Jul 08 2009 11:03 AM UTC
I would like $unset/$rename too.

Let's say we have { _id : 1, toberemoved : 'hello', dontremove :
'world' }

1) $db.foo.save( { _id : 1, dontremove : 'world' });
Could have concurrency issues.

2) $db.foo.update( { _id : 1, toberemoved : 'hello', dontremove :
'world' }, { _id : 1, dontremove : 'world' } );
Will fail if another process already changed the object.

3) $db.foo.update( { _id : 1 }, { $unset : { toberemoved : 1 } } );
This will never fail nor have any concurrency issues -ideal behavior-,

Wouter added a comment - Sep 01 2009 03:31 PM UTC
Please make $unset compatible with arrays aswell, so that I can unset a value in an array based on it's key:

$unset : { 'comments.5' : TRUE }

Mathias Stearn added a comment - Oct 28 2009 05:45 PM UTC
Splitting to two issues. If you want $reduce, watch or vote for http://jira.mongodb.org/browse/SERVER-394

auto added a comment - Dec 11 2009 04:03 PM UTC
Author:{'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}
Message: $unset support in update. SERVER-134
http://github.com/mongodb/mongo/commit/cb16e7c62b094c81fd443b6f33f9b72b2f5a58f9