2.2.6 • Published 1 year ago

dbchain-js-client v2.2.6

Weekly downloads
4
License
ISC
Repository
github
Last release
1 year ago

中文

dbChain js-client


dbChain js-client is the JavaScript implementation of the client side library of dbChain, the blockchain database. With the js-client, developers can quickly start a dbChain application in minutes.

The js-client provides JavaScript functions for

  • Generating mnemonic and private/public key pairs
  • Checking whether key exists
  • Accessing passphrase
  • Retrieving list of tables of a database
  • Retrieving the options of a talbe
  • Retrieving columns of a table
  • Retrieving options of a column
  • Inserting a row into a table
  • Retrieving all rows of a table
  • Searching for rows contain certain field value

Install

yarn add dbchain-js-client

or

npm install --save dbchain-js-client

Usage

Generating mnemonic and private/public key pais

import { newMnemonic, createAndStoreKey } from "dbchain-js-client";

const mnemonic = newMnemonic();
// brown deliver ignore estate adjust pond final inject wear return sword silent
const passphrase = "123345678"
createAndStoreKey(mnemonic, passphrase)

Checking whether key exists

import { hasKey } from 'dbchain-js-client;
if(!hasKey()) {
  console.log("User needs to generate and save key pairs")
}

Accessing passphrase

import { hasPassphrase, savePassphrase } from 'dbchain-js-client;

if(!hasPassphrase()) {
  console.log("User needs to input passphrase");
}

// when user login with a passphrase, we usually save it to browser session storage
var passphrase = "12345678"
if (savePassphrase(passphrase)) {
  console.log("passphrase saved successfully");
} else {
  console.log("passphrase is invalid");
}

Retrieving list of tables of a database

import { getTables } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tables = await getTables(appCode);
/*
[
  "supplier",
  "product",
  "customer"
]
*/

Retrieving the options of a table

import { getTableOptions } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";
const options = await getTableOptions(appCode, tableName);
/*
[
  "public"
]
*/

Retrieving columns of a table

import { getTable } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";
const options = await getTable(appCode, tableName);
/*
[
  "name",
  "phone",
  "address_id"
]
*/

Retrieving options of a column

import { getFieldOptions } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";
const fieldName = "phone";
const options = await getFieldOptions(appCode, tableName, fieldName);
/*
[
  "not-null"
]
*/

Inserting a row into a table

import { insertRow } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";

var record = {};
record.name = "Super supplier"
record.phone = "18888888888";
record.address_id = "5";

const options = await insertRow(appCode, tableName, record, function() {
  console.log("inserting record succeeded");
});

Retrieving id of all rows in a table

import { getAllIds } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";
const ids = await getAllIds(appCode, tableName);
/*
[
  "1",
  "2",
  "3",
  "4"
]
*/

Retrieving a row from a table

import { getRow } from "dbchain-js-client";

const appCode = "DJ1PGEQ45A";
const tableName = "supplier";
const record = await getRow(appCode, tableName, "1");
/*
{
  name: "Super supplier",
  phone: "18888888888",
  address_id: "5"
}
*/

License

dbChain js-client is licensed under the Apache-2.0 License.

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.6

1 year ago

2.1.9

2 years ago

2.1.10

2 years ago

2.1.6

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.2

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.5

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

1.3.17

3 years ago

1.3.16

3 years ago

1.3.15

3 years ago

1.3.14

3 years ago

1.3.13

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.10

4 years ago

1.2.8

4 years ago

1.2.9

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

4 years ago

1.1.12

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago