Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Connection

A connection to AntidoteDB with methods for reading, updating and starting transactions. Use the connect function to obtain a Connection.

The Connection can then be used as a CrdtFactory to create references to database objects.

The readBatch and update methods can be used to perform reads and updates.

Example:

let antidote = antidoteClient.connect(8087, "localhost")
// create a reference to a set object:
let userSet = antidote.set("users")
// read the value of the set
let val = await userSet.read()
// update the set:
await antidote.update(userSet.add("Hans"))

The bucket can be configured via the property defaultBucket, it defaults to "default-bucket".

Javascript objects stored in sets and registers are encoded using MessagePack (http://msgpack.org) by default. You can override the jsToBinary and binaryToJs methods to customize this behavior.

Hierarchy

Implemented by

Index

Properties

dataFormat

dataFormat: DataFormat

The DataFormat to use for decoding and encoding binary values. The default is MsgpackDataFormat.

defaultBucket

defaultBucket: string

the default bucket used for newly created keys

minSnapshotTime

minSnapshotTime: ByteBuffer | undefined

The minimum snapshot version to use for new transactions. This will be used when starting a new transaction in order to guarantee session guarantees like monotonic reads and read-your-writes

monotonicSnapshots

monotonicSnapshots: boolean

Option, which determines if snapshots should be monotonic. If set to true, this will update minSnapshotTime whenever lastCommitTimestamp is updated

Methods

binaryToJs

  • binaryToJs(byteBuffer: ByteBuffer): any
  • Inverse of jsToBinary

    Parameters

    • byteBuffer: ByteBuffer

    Returns any

close

  • close(): void
  • Closes the connection to Antidote

    Returns void

counter

fatCounter

flag_dw

flag_ew

getLastCommitTimestamp

  • getLastCommitTimestamp(): ByteBuffer | undefined
  • returns the timestamp for the last commited transaction

    Returns ByteBuffer | undefined

gmap

jsToBinary

  • jsToBinary(obj: any): ByteBuffer
  • Method to encode objects before they are written to the database

    Parameters

    • obj: any

    Returns ByteBuffer

multiValueRegister

readBatch

  • Takes an array of objects and reads the value of all objects in one batch operation. Returns a promise to an array of values in the same order.

    Hint: To read a single object, use the read method on that object.

    Parameters

    Returns Promise<any[]>

readObjectsBatch

  • readObjectsBatch<T>(objects: object): Promise<object>
  • Reads several objects at once. The objects are stored in an object. Returns a new object with the read values stored under the same field in the object.

        let objA = connection.counter("batch-object-read counter a")
        let objB = connection.register<string>("batch-object-read register b")
    
        let vals = await connection.readObjectsBatch({
            a: objA,
            b: objB
        });
        // could return: {a: 1, b: "hi"}
    

    Hint: To read a single object, use the read method on that object.

    Type parameters

    • T

    Parameters

    • objects: object

    Returns Promise<object>

register

rrmap

set

setTimeout

  • setTimeout(ms: number): void
  • Sets the timout for requests

    Parameters

    • ms: number

    Returns void

set_removeWins

  • set_removeWins<T>(key: string): CrdtSet<T>

startTransaction

update

  • update(updates: ApbUpdateOp[] | ApbUpdateOp): Promise<any>
  • Sends a single update operation or an array of update operations to Antidote. If an array of updates is given, all updates in the array are executed atomically.

    Parameters

    • updates: ApbUpdateOp[] | ApbUpdateOp

    Returns Promise<any>

Generated using TypeDoc