Members
-
<static> $inc
-
Description
Increments a field by the amount you specify. It takes the form
{ $inc: { field1: amount } }
Examples
var probe = require("documents/probe"); probe.update( obj, {'name.last' : 'Owen', 'name.first' : 'LeRoy'}, {$inc : {'password.changes' : 2}} );
Details
-
<static> $dec
-
Description
Decrements a field by the amount you specify. It takes the form
{ $dec: { field1: amount }
Examples
var probe = require("documents/probe"); probe.update( obj, {'name.last' : 'Owen', 'name.first' : 'LeRoy'}, {$dec : {'password.changes' : 2}} );
Details
-
<static> $unset
-
Description
Removes the field from the object. It takes the form
{ $unset: { field1: "" } }
Examples
var probe = require("documents/probe"); probe.update( data, {'name.first' : 'Yogi'}, {$unset : {'name.first' : ''}} );
Details
-
<static> $pop
-
Description
The $pop operator removes the first or last element of an array. Pass $pop a value of 1 to remove the last element
in an array and a value of -1 to remove the first element of an array. This will only work on arrays. Syntax:{ $pop: { field: 1 } }
or{ $pop: { field: -1 } }
Examples
var probe = require("documents/probe"); // attr is the name of the array field probe.update( data, {_id : '511d18827da2b88b09000133'}, {$pop : {attr : 1}} );
Details
-
<static> $push
-
Description
The $push operator appends a specified value to an array. It looks like this:
{ $push: { <field>: <value> } }
Examples
var probe = require("documents/probe"); // attr is the name of the array field probe.update( data, {_id : '511d18827da2b88b09000133'}, {$push : {attr : {"hand" : "new", "color" : "new"}}} );
Details
-
<static> $pull
-
Description
The $pull operator removes all instances of a value from an existing array. It looks like this:
{ $pull: { field: <query> } }
Examples
var probe = require("documents/probe"); // attr is the name of the array field probe.update( data, {'email' : 'EWallace.43@fauxprisons.com'}, {$pull : {attr : {"color" : "green"}}} );
Details