Coder Social home page Coder Social logo

node-ebakusdb's Introduction

node-ebakusdb

A driver for node.js for interacting with the EbakusDB running on an Ebakus Blockchain network.

You can find example use cases in the examples folder.

EbakusDBClient

This class allows interaction with the EbaksuDB running on the Ebakus Blockchain node.

Kind: global class

new EbakusDBClient(options, [localSigning], address, keystoreV3, keystoreV3Pass, schema)

Create a connection with EbakusDB.

Throws:

  • EbakusDBError
Param Type Default Description
options Object The options for this connections.
[options.secure] boolean false Whether to use https or not.
[options.host] string "localhost" The Ebakus node RPC host.
[options.port] number 8545 The Ebakus node RPC port.
[localSigning] boolean false Whether signing will be done locally or on the remote Ebakus Node.
address string The unlocked address on the remote Ebakus node.
keystoreV3 string | object The keystore V3 object or full path to a keystore file.
keystoreV3Pass string The password to unlock the keystoreV3.
schema Object EbakusDB tables schema. Read more below.

Example schema object

The schema has to be defined correctly once and cannot be changed. The schema will be stored on the Ebakus blockchain during the table creation.

IMPORTANT: The inputs names has to be pascal case, which means the first character has to be uppercase.

  schema: {
    Users: {
      type: 'table',
      name: 'Users',
      inputs: [
        { name: 'Id', type: 'uint64' },
        { name: 'Name', type: 'string' },
        { name: 'Email', type: 'string' },
      ],
    },
    Files: {
      type: 'table',
      name: 'Files',
      inputs: [
        { name: 'Id', type: 'string' },
        { name: 'Type', type: 'string' },
      ],
    },
  },

ebakusDBClient.createTable(tableName, [indexes]) ⇒ boolean

This has to be called once per table. Important, "Id" field has to exist in every table/struct.

Kind: instance method of EbakusDBClient Throws:

  • EbakusDBErrorTransactionFailureErrorReplyError
Param Type Default Description
tableName string Table name as defined in the schema.
[indexes] Array.<string> [] List of indexed fields.

ebakusDBClient.get(tableName, whereClause, orderClause, [blockNumber]) ⇒ Object

Transaction will fail if nothing is mathed in EbakusDB.

Kind: instance method of EbakusDBClient Returns: Object - The data object read from EbakusDB. Throws:

  • Error
Param Type Default Description
tableName string Table name as defined in the schema.
whereClause string WhereClause for finding an entry. Supported conditions are "<", ">", "=", "==", "<=", ">=", "!=", "LIKE" Example use case: Phone = "555-1111" Id >= 3
orderClause string OrderClause for sorting the results using "ASC" or "DESC". Example use case: Phone DESC
[blockNumber] string "latest" The block number from which to read data

ebakusDBClient.select(tableName, whereClause, orderClause, [blockNumber])

Select entries from EbakusDB

Kind: instance method of EbakusDBClient Throws:

  • EbakusDBError
Param Type Default Description
tableName string Table name as defined in the schema.
whereClause string WhereClause for finding an entry. Supported conditions are "<", ">", "=", "==", "<=", ">=", "!=", "LIKE" Example use case: Phone = "555-1111" Id >= 3
orderClause string OrderClause for sorting the results using "ASC" or "DESC". Example use case: Phone DESC
[blockNumber] string "latest" The block number from which to read data

ebakusDBClient.insertObj(tableName, object) ⇒ boolean

Insert/Update an entry in EbakusDB.

Kind: instance method of EbakusDBClient Returns: boolean - Whether entry has been inserted/updated. Throws:

  • TransactionFailureErrorReplyError
Param Type Description
tableName string Table name as defined in the schema.
object Object Object data.

ebakusDBClient.deleteObj(tableName, input) ⇒ boolean

Delete an entry in EbakusDB.

Kind: instance method of EbakusDBClient Returns: boolean - Whether entry has been deleted. Throws:

  • TransactionFailureErrorReplyError
Param Type Description
tableName string Table name as defined in the schema.
input Object | * Object data.
input.Id * The Id of the entry for this table.

node-ebakusdb's People

Contributors

ziogaschr avatar harkal avatar

Stargazers

 avatar

Forkers

ziogaschr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.