1.0.19 • Published 7 years ago
ora-ruffle v1.0.19
Ruffle
Installation
npm install ora-ruffleExample Usage
Importing
const Ruffle = require('ora-ruffle')
var ruffle = new Ruffle()Creating a table for transactions
let table = "transactions"
let schema = {
id: 'string',
from: 'string',
to: 'string',
amount: 'uint'
}
var transactions = ruffle.create(table, schema)Load table for transactions
let table = "transactions"
let schema = {
id: 'string',
from: 'string',
to: 'string',
amount: 'uint'
}
var transactions = ruffle.create(table, schema)Put key into db
let key = 'id'
let transaction = {
id: key,
from: 'address1',
to: 'address2',
amount: 20000
}
ruffle.put(transactions, key, value)The put command returns a proof and value, or an error.
Proof {
}Get item from the table
ruffle.get(transactions, key)let pred = {
account: "key"
}
ruffle.filter(transactions, pred)Documentation
CRUD Operations
Create
| name | type | description |
|---|---|---|
| table | string | name of the table |
| schema | JSON | schema for the table |
This creates a table with name, tableName, and returns a confirmation boolean if correct.
let table = "transactions"
let schema = {
balance: 'uint'
account: 'string'
}
var transactions = ruffle.create(table, schema)Put
| name | type | description |
|---|---|---|
| tableName | string | name of the table |
| key | byte array | key for the value |
| value | bytes array | value being placed in the table |
This operation does a put, and returns a proof.
let key = '.....'
let value = {
account: key,
value: 1000
}
ruffle.put(transactions, key, value)Get
| name | type | description |
|---|---|---|
| table | string | name of the table |
| key | byte array | key for the value |
Gets a value corresponding to the key, within the tableName.
ruffle.get(transactions, key)Remove
| name | type | description |
|---|---|---|
| tableName | string | name of the table |
| key | byte array | key for the value |
Deletes the value associated with the key at the designated table.
Verification
Filters, Aggregates, Maps, and Groups
Filter
Each filter can be shown as a combination of three variables.
| name | type | description |
|---|---|---|
| name | string | name of the table |
| expression | string | key for the predicate type |
| value | integer, string, value type | key for the value |
let filter = [{
name: "name", expression: "=", value: "hello"
}]
ruffle.filter(transactions, filter)Output
Future Work
Future work on this library:
- Schema Validation
- Optimized range queries
- Integrating mapping, and aggregation functions
- Query optimization
- Addition of developer-based authenticated updates
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago