New in 1.33.0 (BETA)


A DataScope allows application developers to interact with data referenced by a DataLocator. In order to retrieve a DataScope from the current data, the Scrivito.useData hook can be used.

New in 1.41.0

Single-item vs. multi-item

A DataScope is a single-item scope if it can inherently contain only one item. This is the case if and only if the corresponding DataLocator has at least one filter for the _id attribute. Otherwise, a DataScope is a multi-item scope.

A DataScope that incidentally contains one item is not a single-item scope. So “All Orders” is still a multi-item DataScope, even if currently only one order exists.

Instance method summary

  • containsData()
    Checks if this DataScope contains at least one item.
  • count()
    Returns the total number of items in the given DataScope.
  • create(attributes)
    Creates data and returns a corresponding new DataItem instance. The attributes are provided to the corresponding create callback (see Scrivito.provideDataClass).
  • dataClass()
    Returns the DataClass instance of the DataScope.
  • dataClassName()
    Returns the name of the DataClass of the DataScope.
  • dataItem()
    Loads and returns the corresponding DataItem if the DataScope is a single-item scope.
  • getError()
    Returns a DataScopeError instance if a connection error occurs during data retrieval for a DataScope, or an error occurs while a DataLocator is being evaluated inside Scrivito.useDataLocator.
  • isDataItem()
    Checks if the DataScope is a single-item scope.  
  • isEmpty()
    Checks if this DataScope doesn’t contain any items.
  • objSearch()
    Returns an ObjSearch instance of the DataScope.
  • take()
    Evaluates the transformation of the DataScope and returns the corresponding data items.
  • transform(params)
    Returns a new DataScope instance with applied transformations specified by the params. The parameters are provided to the corresponding index callback as IndexParams.