Skip to content

index API

phoenixide edited this page Feb 1, 2023 · 3 revisions

Installing the library

npm install @aicore/cocodb-ws-client

importing in your js file

import * as coco from "@aicore/cocodb-ws-client"; // to import all functions

Initializing the client

Create a connection to the cocoDbServiceEndPoint and listens for messages. The connection will be maintained and it will try to automatically re-establish broken connections if there are network issues. You need to await on this function before staring to use any db APIs. Any APIs called while the connection is not fully setup will throw an error.

Parameters

  • cocoDbServiceEndPoint [string][1] The URL of the coco-db service.
  • authKey [string][1] The authKey is a base64 encoded string of the username and password.

Returns [Promise][2]<null> Resolves when the cocodb client is ready to send/receive requests for the first time. Rejects only if the user calls close API before any connection is established.

await db.init("ws://endpoint.coco", "your_auth_key");

Detailed API Docs

See this wiki for detailed API docs

close the client

Closes the connection to the server. You need to await on this function before you can call init again.

Returns [Promise][2]<null> Resolves when the cocodb client is closed and you are free to call init again. Never rejects.

await db.close();

Clone this wiki locally