Last active
August 29, 2015 14:19
-
-
Save laurentsab/63147f93dbfd8cef3ad5 to your computer and use it in GitHub Desktop.
MongoDB Tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Update/Add a new field | |
Rooms.update({_id: 'XDhybphgkdC7Z4dsn'}, {$set: {user: 'Laurent'}}); | |
// Add array | |
Rooms.update({_id: 'XDhybphgkdC7Z4dsn'}, {$set: {objects: ['TV', 'Radio', 'Draps'] } } ); | |
// Push a field in an array | |
Rooms.update({_id: 'XDhybphgkdC7Z4dsn'}, {$push: {objects: ['Lights'] } } ); | |
// Push an array in an array | |
Rooms.update({_id: 'J5idHne5rrj7Qf7ot'}, {$push: {objects: {$each: [ 'Test1', 'Test2', 'Test3'] } } } ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment