Bucket.updatemethod is called. For performing several updates simultaneously, the
Bucket.updatesmethods can be used. The update method takes a transactional context as the first argument. If the client has to perform a single update or read operation,
NoTransactioncan be used to execute an individual operation without any transactional context. The second argument of update method is an AntidoteDB Key which is explained in detail later in the section.
generatedId()method returns a unique BoardId object for each Board object.
getId()method returns the uniqueID as a String. Since several objects are modeled as a map, it makes sense to have a method that generates an AntidoteDB MapKey corresponding to the map. Consequently, we have the following method that substitutes
map_aw(board_id.getId())on line 4.
register(“name”)in line 4 is replaced with
namefieldso that it constraints the type to
boardKeycreates an update operation to update CRDTs embedded inside the
createboardmethod returns a unique id which can later be passed as an argument for the
renameBoardmethod. Since the
namefieldis a register data type,
assignis called to update the value.
MapReadResultpresents the result of a read request on a Map CRDT. The entire object is read from database and individual fields can be obtained using get methods as illustrated by the following code:
InteractiveTransactionallows a client to execute multiple update and read before committing the transaction. It constitutes of a sequence of operations performed as a single logical unit. If the client has to perform a single update or read operation, the
NoTransactioncan be used to execute an individual operation without any transactional context.
moveTaskmethod deletes a task from one column and adds it to another column. It takes
ColumnIdof the new column and
InteractiveTransactionis called to ensure that the reads and updates are performed as a single unit.
InteractiveTransactionguarantees that either the entire sequence of operation executes or none of them do. Hence we avoid the case in which the operation to delete a task from one column is performed but the operation to add a task to another is not.
columnbucketin line 4 takes the transactional context
txcreated in line 1 as its first argument and reads the old
ColumnId. In lines 5 and 7,
newcolumnKeyare used to update the contents of the Map CRDT
boardMap) in the database. Line 6 removes the Task Id from the
oldcolumnKeyand line 8 adds the
newcolumnKey. On line 10, the transaction is committed by calling