UpdateOperation

Operation defaults are dryRun(false), grant(null), lean(true), skipAcl(false).

dryRun(bool = true)
execute()
grant(level)
lean(bool = true)
pathDelete(path = null)
pathPrefix(path = null)
pathPush(path = null, body)
pathUpdate(path = null, body)
skipAcl(bool = true)

const Items = org.objects.c_items;

const _id = Items.updateOne({c_key: 'unique key'}, {c_key: 'very unique'})
  .skipAcl()
  .grant(consts.accessLevels.update)  
  .execute();
  
return Items.find({_id: _id}).paths('c_key').next();

UpdateOperation.dryRun(bool = true)

The operation performs a dry run. Though no documents are updated, before triggers are called.

Arguments

  • bool (Boolean)

Returns

this

UpdateOperation.execute()

Executes the operation.

Returns

ObjectID|Object If the lean option is turned off, the entire updated document is returned. When true, only the identifier is returned.

UpdateOperation.grant(level)

Sets the grant level for the operation.

Arguments

  • level (Number)

Returns

this

UpdateOperation.lean(bool = true)

On by default, turning off this option reads the entire updated document after execution. "modified" may also be used to return an object containing just the modified properties.

Arguments

  • bool (Boolean)

Returns

this

UpdateOperation.pathDelete(path = null)

Deletes a single property or array value using the current cursor options. Passing a path argument overwrites the pathPrefix() option. For example, org.objects.c_object.updateOne({_id: _id}).pathDelete("c_docs.5a2c44f836412438e4c372c2.c_array.bar"); removes "bar" from the c_array string array in the c_docs document array.

Arguments

  • path (String) Optional. Overrides pathPrefix().

Returns

Object

UpdateOperation.pathPrefix(path = null)

Sets or removes the operation path prefix. When a prefix is present the operation can target documents in a write-through list or nested document array. For example, c_parent.updateOne({_id: parentId}, {$push: [{c_name: 'new child'}]}).pathPrefix('c_children').execute() creates a new c_child instance through the c_parent object's c_children list property.

Arguments

  • path (String)

Returns

this

UpdateOperation.pathPush(path = null, body)

Shortcut for updateOne(..., {$push: [body]}).pathPrefix(path).execute()

Arguments

  • path (String) Optional. Overrides pathPrefix().
  • body (Object) The value(s) to push.

Returns

Object

UpdateOperation.pathUpdate(path = null, body)

Shortcut for updateOne(..., {$set: [body]}).pathPrefix(path).execute()

Arguments

  • path (String) Optional. Overrides pathPrefix().
  • body (Object) The value(s) to update.

Returns

Object

UpdateOperation.skipAcl(bool = true)

Skips property acl checks.

Arguments

  • bool (Boolean)

Returns

this