Interface: RecordCollectionsMonitor

x2node-dbos. RecordCollectionsMonitor

Interface for components that monitor updates to record collections of each record type as a whole.

Methods


collectionsUpdated(ctx, recordTypeNames)

Called by the DBOs from within the transactions when records of the given record types are modified. The method is called just before the transaction is committed.
Parameters:
Name Type Description
ctx module:x2node-dbos~DBOExecutionContext DBO execution context.
recordTypeNames Array.<string> | Set.<string> Names of updated record types. Allowed to be null, undefined or empty.
Returns:
If a Promise is returned, the transaction is not committed until the promise is fulfilled. If the promise is rejected, the whole transaction gets rolled back. Any other type of returned value is ignored and the transaction is committed immediately.
Type
Promise

getCollectionsVersion(tx, recordTypeNames [, lockType])

Get record collection version information for the specified record types.
Parameters:
Name Type Argument Description
tx module:x2node-dbos~Transaction The transaction.
recordTypeNames string | Array.<string> | Iterable.<string> Names of the record types to include.
lockType string <optional>
If provided, the collections are locked until the end of the transaction. The value can be either "shared" or "exclusive".
Returns:
Promise of the result object. The result object includes two properties: modifiedOn, which is a Date representing the last modification timestamp of the records collection among the requested ones that was modified most recently, and version, which is a number that is a sum of all requested record collection versions.
Type
Promise.<Object>

lockCollections(tx, recordTypeNames, lockType)

Lock record collection(s) for the transaction. This is similar to module:x2node-dbos.RecordCollectionsMonitor#getCollectionsVersion with a lockType argument, but may be a little more lightweight as it does not require to fetch any collection version data.
Parameters:
Name Type Description
tx module:x2node-dbos~Transaction The transaction.
recordTypeNames string | Array.<string> | Iterable.<string> Names of the record types to lock.
lockType string The lock type, which can be either "shared" or "exclusive".
Returns:
Promise that is fulfilled after the lock is placed.
Type
Promise.<Object>