ora-ruffle
v1.0.19
Published
Ruffle authenticated database
Downloads
6
Readme
Ruffle
Installation
npm install ora-ruffle
Example 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