Options
All
  • Public
  • Public/Protected
  • All
Menu
internal

Type parameters

  • Q

Hierarchy

Index

Constructors

constructor

Methods

set

  • set(properties: SetProperties, options?: SetOptions): Q
  • 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 = $userId

    set 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.

    Parameters

    • properties: SetProperties
    • Optional options: SetOptions

    Returns Q

setLabels

  • setLabels(labels: Dictionary<Many<string>>): Q
  • Adds labels to a node using a set clause.

    query.setLabels({
      sale: 'Active',
    })
    // SET sale:Active

    setLabels 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.

    Parameters

    • labels: Dictionary<Many<string>>

    Returns Q

setValues

  • setValues(values: Dictionary<any>, merge?: undefined | false | true): Q
  • 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 += $userId

    setValues 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

    Parameters

    • values: Dictionary<any>
    • Optional merge: undefined | false | true

    Returns Q

setVariables

  • setVariables(variables: Dictionary<string | Dictionary<string>>, merge?: undefined | false | true): Q
  • 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

    Parameters

    • variables: Dictionary<string | Dictionary<string>>
    • Optional merge: undefined | false | true

    Returns Q

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc