Skip to content

Connection (NodeJS)

Dmitry Kochin edited this page Jul 10, 2018 · 6 revisions

You communicate to a Ties.DB node with Connection object.

Creating a connection object

let c = new Connection();

Connecting to Ties.DB node

await c.connect('ws://<node address>:<port>');

Ties.DB protocol uses WebSocket at transport layer. So you should pass ws:// schema as connect argument.

Insert or modify records

let response = await c.modify(records, pk);

Arguments

  • records - array of Record objects
  • pk - Buffer, containing the user's private key

Returns

Tag object containing response in Ties.DB EBML format. It is either ModificationResponse or Error tag.

You can pass several records in modification request. The records can insert or update rows. Since each request should be signed you need to pass your private key in pk argument.

Retrieve records

let response = await c.recollect(tiql, pk);

Arguments

  • tiql - TiQL query
  • pk - Buffer, containing the user's private key

Returns

Tag object containing response in Ties.DB EBML format. It is either RecollectionResponse or Error tag.

You can retrieve records with TiQL query. Since each request should be signed you need to pass your private key in pk argument

Closing connection

c.close()

Clone this wiki locally