A CRAB-based ORM for BigchainDB.
CRAB is the CRUD model in databases applied to blockchains:
Database | Blockchain |
---|---|
Create | Create |
Read | Retrieve |
Update | Append |
Delete | Burn |
Breaking changes
- **Version 3.x ** of js-driver-orm changes namespacing of data storage and retrieval. Using new version with old data will brake it!
Table of Contents
Setup
$ npm install bigchaindb-orm
Usage
// import bigchaindb-orm// connect to BigchainDBconst bdbOrm = "https://test.bigchaindb.com/api/v1/" app_id: "Get one from testnet.bigchaindb.com" app_key: "Get one from testnet.bigchaindb.com" // define(<model name>,<additional information>)// <model name>: represents the name of model you want to store// <additional inf.>: any information you want to pass about the model (can be string or object)// note: cannot be changed once set!bdbOrm// create a public and private key for Aliceconst aliceKeypair =
Examples
All examples need bdbOrm initialized as described in usage
Example: Create an asset
// from the defined models in our bdbOrm we create an asset with Alice as ownerbdbOrmmodelsmyModel
Example: Retrieve assets
// get all objects with retrieve()// or get a specific object with retrieve(object.id)bdbOrmmodelsmyModel
Example: Append a transaction
"Update" (Database) => "Append" (Blockchain)
// create an asset with Alice as ownerbdbOrmmodelsmyModel
Example: Burn an asset
"Delete" (Database) => "Burn" (Blockchain)
❗️Burning assets does not delete them! It moves control of asset from users keypair to unfulfillable one.❗️
// create an asset with Alice as ownerbdbOrmmodelsmyModel
License
Copyright 2018 BigchainDB GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.