Mixin: Locking

Locking

This mixin grants the capability of locking reads, within an underlying transaction for a lookup statement, via composition.
See:

Members


<static, readonly> LockContention :number

Enum to identify row locking modes.
Type:
  • number
See:
Example
LockContention.DEFAULT
LockContention.NOWAIT
LockContention.SKIP_LOCKED

Methods


lockExclusive( [mode])

Uses a exclusive mode lock on any records or documents that are read by the statement, where other sessions cannot even read the same records or documents until the transaction commits. This method does not cause the statement to be executed but changes the statement boundaries, which means that if it has been prepared before, it needs to be re-prepared.
Parameters:
Name Type Argument Description
mode LockContention <optional>
A value that determines the locking concurrency options.
Returns:
Instance of the statement itself following a fluent API convention.
Type
Locking
Example
collection.find().lockExclusive();
collection.find().lockExclusive(mysqlx.LockContention.NOWAIT)
collection.find().lockExclusive(mysqlx.LockContention.SKIP_LOCKED)

lockShared( [mode])

Uses a shared mode lock on any records or documents that are read by the statement, where other sessions can also read the same records or documents but cannot modify them until the transaction commits. This method does not cause the statement to be executed but changes the statement boundaries, which means that if it has been prepared before, it needs to be re-prepared.
Parameters:
Name Type Argument Description
mode LockContention <optional>
A value that determines the locking concurrency options.
Returns:
The instance of the statement itself following a fluent API convention.
Type
Locking
Example
collection.find().lockShared();
collection.find().lockShared(mysqlx.LockContention.NOWAIT)
collection.find().lockShared(mysqlx.LockContention.SKIP_LOCKED)