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.
This class allows interaction with the EbaksuDB running on the Ebakus Blockchain node.
Kind: global class
- node-ebakusdb
- EbakusDBClient
- new EbakusDBClient(options, [localSigning], address, keystoreV3, keystoreV3Pass, schema)
- ebakusDBClient.createTable(tableName, [indexes]) ⇒
boolean
- ebakusDBClient.get(tableName, whereClause, orderClause, [blockNumber]) ⇒
Object
- ebakusDBClient.select(tableName, whereClause, orderClause, [blockNumber])
- ebakusDBClient.insertObj(tableName, object) ⇒
boolean
- ebakusDBClient.deleteObj(tableName, input) ⇒
boolean
- EbakusDBClient
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. |
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' },
],
},
},
This has to be called once per table. Important, "Id" field has to exist in every table/struct.
Kind: instance method of EbakusDBClient
Throws:
EbakusDBError
TransactionFailureError
ReplyError
Param | Type | Default | Description |
---|---|---|---|
tableName | string |
Table name as defined in the schema. | |
[indexes] | Array.<string> |
[] |
List of indexed fields. |
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 |
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 |
Insert/Update an entry in EbakusDB.
Kind: instance method of EbakusDBClient
Returns: boolean
- Whether entry has been inserted/updated.
Throws:
TransactionFailureError
ReplyError
Param | Type | Description |
---|---|---|
tableName | string |
Table name as defined in the schema. |
object | Object |
Object data. |
Delete an entry in EbakusDB.
Kind: instance method of EbakusDBClient
Returns: boolean
- Whether entry has been deleted.
Throws:
TransactionFailureError
ReplyError
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. |