npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

orwelldb

v0.0.14

Published

Library, wich helps syncronize blockchain and any database use datascript protocol to write operations (can be wroten in blockchain transactions hex like scriptSig or scriptPubKey)

Downloads

31

Readme

Idea

orwelldb

Library which synchronize data between blockchain and database

based

All protocol based on network bitcoin types, like var_int, var_str and other. You can find this types and parser/builder for that in my another package: bitPony

Orwelldb usage

install

npm install orwelldb

add to app

var orwelldb = require('orwelldb');

interface


orwelldb.import(orwell_params, 'script or array of script')//returns Promise object
orwelldb.export(orwell_params, execFunction)//returns Promise object
orwelldb.$(orwell_params) //access to db api. return Promise
orwelldb.datascript //datascript builder/parser

orwell params

{
	adapter: mysqlAdapter,//database adapter object or empty for using native (nosql lokijs)
	name: 'db1',//database name
	public_key: "", //writer or owner public key
	keystore: {//keystore settings, for example can be used another user to keystore, or another adapter
		adapter: mysqlAdapter, //keystore db adapter
		name: 'keystore', //keystore database name
		options: { //keystore adapter options (for mysql need auth data)
			dbuser: 'orwelldb',
			dbpass: '',
			modelspath: '../_tests/models/keystore' //node-orm2 use models file with shema defenition
		}
	},
	options: { //adapter options
		dbuser: 'orwelldb',
		dbpass: '',
		modelspath: '../_tests/models/index' 
	}
}

import

new orwellsb.import(orwell_params, 'ef....datascript hex...')
.then(function (results) {
    //results is array of import result
})
.catch(function (e) {
    //error if have
})

import result

{ 
    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.
 }

export

orwelldb.export(orwell_params, function (db) {

        //actions in this function create datascript after result.
        //must return promise!
        //operations generated datascript in version 0.0.1: write, create, setSettings
        //for example create dataset posts, after that write data {oid: '7f5aea2ff97f', title: 'test1', 'text': 'what?!'}
	return db.create('posts', {privileges: [], writeScript: ''})
			.then(function (res) {
				return db.write("posts", {oid: '7f5aea2ff97f', title: 'test1', 'text': 'what?!'})
			})
})
	.then(function (hex) {

		//hex - datascript, contains all operation in one transaction
                //ef....
                // create dataset posts then write data

	})

database

var $ = orwelldb.$;

$(orwell_options)
.then(function (db) {
	return db.getCollection("posts")
})
.then(function (dataset) {//first time may be throwned, but second and next - okay
	return dataset.findItems()
})
.then(function (list) {
	
})
.catch(function (err) {
	console.log(err)
})

interface descriped in wiki.

datascript

var datascript = orwelldb.datascript;

parse

var obj = new datascript('hex or buffer', pem);
obj.toJSON();

return:

{
        dataset: 'dataset name',
        operator: 'operation',//write, create, settings
        content: {},//data
        canRead: true, // if false - datascript encrypted, need pem
        success: true // if false - datascript is not valid
}

build

var obj = new datascript({
    operation: 'write',
    dataset: 'posts',
    content: obj, 
    algorithm: 'rsa' // rsa or ecdh
}, pem);
obj.toHEX(); //returns hex string of datascript buffer.

More information and examples you can read in orwelldb wiki: wiki