-
Notifications
You must be signed in to change notification settings - Fork 1
2. Import
Nanocat edited this page Sep 14, 2017
·
4 revisions
import assume that you recive new datascript from blockchain and import hex of datascript into orwelldb. which decide - add into database or not this information. Existence of information is checked by the field oid in data.
If you have private keys to decrypt datascript - it need to be added before import. Not decrypted data not syncing in database.
orwelldb.import(orwell_params, 'ef....datascript hex...')
.then(function (results) {
//results is array of import result
})
.catch(function (e) {
//error if have
})Format of decrypted datascript is js object named scenario, which contain all information from datascript and can be converted back to datascript or writed into database. Result also contain field data, which contain information from database with meta data.
Status of result can be on of the next values:
success
0
ok
error (all error details in field error):
dberror // database error
cantWrite // dataset settings do not accept writing for you key
cantChange // cant change settings for this dataset with this public key
cantRead // you cant read this entryes, without keys
{
operation: 'update',//operation insert/update
data: //data from database (with meta data)
{ oid: 1,
writeScript: 5560,
owner_key: '',
privileges: [],
meta: [Object],
'$loki': 1 },
scenario: //scenario, datascript generated from
{ operation: 'create', //datascript operation
dataset: 'posts', //dataset name
content: { oid: 1,
writeScript: 5560,
owner_key: '',
privileges: [], },
algorithm: 'rsa' }, //if have keystore for this db\dataset - encryption is enabled
status: 0 //0 = ok, another status from 0 or 'ok' its error, error description in error field.
}