Adds a set clause to the query.
set lets you updates a nodes labels and properties in one clause. Most of
the time it will be easier to use one of the variants such as setLabels,
setValues or setVariables.
This function accepts three different kind of properties, each of which is described in more detail in the variants.
query.set({
labels: {
sale: 'Active',
},
variables: {
sale: {
activatedAt: 'timestamp()',
},
},
values: {
sale: {
activatedBy: user.id,
},
},
})
// SET sale:Active, sale.activatedAt = timestamp(), sale.activatedBy = $userIdset also accepts an options object which currently only contains a
single setting: override. Override controls whether the = or +=
operator is used in the set clause. true causes the existing object to be
cleared and replaced by the new object. false on the other hand will
merge the existing and new objects together, with new properties replacing
the ones on the existing object.
The default value of override is a little inconsistent and it will be
improved in the next major version. If you don't pass any settings object,
override will default to true. If you pass an options object without an
override key, override will be false. In future versions, override will
always default to false to be more consistent with setVariables and
setValues.
Adds labels to a node using a set clause.
query.setLabels({
sale: 'Active',
})
// SET sale:ActivesetLabels accepts a dictionary where the keys are nodes to be updated
and the value is a single label or an array of labels to add to the node.
Updates a node from parameters using a set
clause. This function treats all values as parameters which is different to
setVariables which assumes values are cypher variables.
query.setValues({
'sale.activatedBy': user.id,
})
// SET sale.activatedBy += $userIdsetValues accepts a dictionary where the keys are nodes or property names
to be updated.
To use the += operator to merge properties of a node, you can pass
true to the merge option.
query.setValues({
'sale': { active: true },
}, true)
// SET sale += $sale
Updates a node from a variable that was previously declared in the query
using a set
clause. This function only accepts strings as its values which are not
escaped in any way so beware. If you want to store some user supplied
information in the database, setValues is the function you want.
query.setVariables({
'sale.activatedAt': 'timestamp()',
})
// SET sale.activatedAt = timestamp()Note how values are inserted into the query, as is.
To use the += operator to merge properties of a node, you can pass
true to the merge option.
query.setVariables({
'sale': 'newSaleDetails'
}, true)
// SET sale += newSaleDetails
Generated using TypeDoc