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

meteor-bigchaindb-collection

v1.0.5

Published

Use BigchainDB in your Meteor application just like you are using Mongo

Downloads

2

Readme

Meteor BigchainDB Collection

Use BigchainDB in your Meteor application just like you are using Mongo

WARNING: this is just an experiment!

How it works?

Data is imediatelly written into your normal Mongo database plus it is sent as an transaction to BigchainDB. After transaction is confirmed by BigchainDB, document is updated with transaction ID and status is changed from "pending" to "ok".

This package is using BigchainDB's event stream to listen for successfull transactions. Data written directly to BigchainDB (by another application or whatever) is detected and written to your application's Mongo database.

In short, Mongo acts as a buffer between your application and BigchainDB.

Usage

Add this package to your Meteor application:

meteor npm install --save meteor-bigchaindb-collection

Add following to your Meteor settings.json:

{
	"bigchaindb": {
		"url": "http://localhost:9984/api/v1/",
		"eventsUrl": "ws://0.0.0.0:9985/api/v1/streams/valid_transactions",
		"namespace": "YOUR_APP_UNIQUE_ID"
	}
}
  • url is URL to BigchainDB server's REST API.
  • eventsUrl is URL to BigchainDB's event stream websocket.
  • namespace is your application's unique id. Can be any string.

Define your collections in both client and server scope:

import {BDBCollection} from "meteor-bigchaindb-collection";

export const MyCollection = new BDBCollection("my_collection");

In Meteor server's startup, create BDB connection and register all BDB collections you have in the app:

import { BDBConnection } from "bigchaindb-collection";

import { MyCollection } from "path to file where you defined your collection";

Meteor.startup(function() {

	let BDBC = new BDBConnection();
	
	BDBC.connect({
		url: Meteor.settings.bigchaindb.url,
		eventsUrl: Meteor.settings.bigchaindb.eventsUrl,
		namespace: Meteor.settings.bigchaindb.namespace
	});

	BDBC.registerCollection(MyCollection);
	
});

Don't forget to start your application with settings.json

meteor --settings settings.json

And use collection as you normally do, but perform inserts server-side only and provide BDB keys as third argument to insert:

let publicKey = "....";
let privateKey = "....";

MyCollection.insert({ hello: "world" }, null, { publicKey: publicKey, privateKey: privateKey });

console.log(MyCollection.find({}).fetch());

You are inside method here, so assuming user's keys are stored in "users" collection, you can get user (caller) with: users.findOne({ _id: this.userId }); and access his private and public key. Or, if keys are fixed at app level, you can read them from Meteor.settings (or whatever)

You'll notice two additional fields in your document:

  • _transactionId - BigchainDB transaction ID. Initially it is null until transaction is confirmed.

  • _transactionStatus - Initially it is "pending" and changes to "ok" after transaction is confirmed.

That all folks

Enjoy!