Class: updateOperators

documents/probe. updateOperators

This is not actually a class, but an artifact of the documentation system


new updateOperators()

These are the supported update operators

Source:

Members


<static> $dec

Decrements a field by the amount you specify. It takes the form
{ $dec: { field1: amount }

Source:
Example
var probe = require("documents/probe");
probe.update( obj, {'name.last' : 'Owen', 'name.first' : 'LeRoy'},
{$dec : {'password.changes' : 2}} );

<static> $inc

Increments a field by the amount you specify. It takes the form
{ $inc: { field1: amount } }

Source:
Example
var probe = require("documents/probe");
probe.update( obj, {'name.last' : 'Owen', 'name.first' : 'LeRoy'},
{$inc : {'password.changes' : 2}} );

<static> $pop

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

Source:
Example
var probe = require("documents/probe");
// attr is the name of the array field
probe.update( data, {_id : '511d18827da2b88b09000133'}, {$pop : {attr : 1}} );

<static> $pull

The $pull operator removes all instances of a value from an existing array. It looks like this:
{ $pull: { field: <query> } }

Source:
Example
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"}}} );

<static> $push

The $push operator appends a specified value to an array. It looks like this:
{ $push: { <field>: <value> } }

Source:
Example
var probe = require("documents/probe");
// attr is the name of the array field
probe.update( data, {_id : '511d18827da2b88b09000133'},
{$push : {attr : {"hand" : "new", "color" : "new"}}} );

<static> $unset

Removes the field from the object. It takes the form
{ $unset: { field1: "" } }

Source:
Example
var probe = require("documents/probe");
probe.update( data, {'name.first' : 'Yogi'}, {$unset : {'name.first' : ''}} );