0.0.6 • Published 11 years ago

nonogo v0.0.6

Weekly downloads
11
License
-
Repository
-
Last release
11 years ago

nonogo v0.0.5

Description

nonogo is a document-based database designed for and written in node.js

Installation

npm install nonogo

Usage

So let's get down to the nitty gritty. Here are the functions you need to know to use nonogo.

nonogo.open(path, cryptoFlag, cryptoAlgo, cryptoKey, callback)

Opens a nonogo database file, or creates it if it doesn't exist. Callback is given two arguments, error and collection.

A word on cryptography...cryptoFlag determines whether the database will be encrypted or plain text. cryptoAlgo is the algorithm to be used for encryption/decryption, usually dictated by algorithms supported by OpenSSL. cryptoKey is the key/password to be used in the encryption/decryption, do not lose or forget this, 'cause there is no way of getting it back, well...I'm sure there is :-)

Example:
nonogo.open('nonogodb', '1', 'RC4', 'asdf', function(error, collection) {
	// Do stuff with collection.
});

The Collection Object

OK, before we move any futher, let's go over this collection object. You really don't even have to name it 'collection', I usually just name it 'd'.

You can use the collection object just as you would any JSON object. Google 'json' if you haven't used it, you'll be up to speed in like 3 minutes, trust me.

Here's an example for referring to the 'name' field in the 60th row of the 'People' key.

Given that the collection object is named 'data'...

var name = data.People[59].name;

or,

var name = data['People'][59]['name'];

This allows you to create all kinds of iterations in order to find data. This is something that will be included in version 0.1.0.

Moving on...


nonogo.addRow(key, value, callback)

Adds a row to a key. If the key does not exist it is created. If null is passed as the key name, one will be generated for you. Callback is given two arguments, error and collection.

Example:
nonogo.addRow('People', {name:'Julio', age:'30'}, function(error, collection) {
	// Do stuff with collection.
});

nonogo.addField(key, index, field, value, callback)

Adds a field to a row. Callback is given two arguments, error and collection.

Example:
nonogo.addField('People', 59, sex, 'male', function(error, collection) {
	// Do stuff with collection.
});

nonogo.editRow(key, index, value, callback)

Edits an entire row. Callback is given two arguments, error and collection.

Example:
nonogo.editRow('People', 59, {name:'Sara', age:'31'}, function(error, collection) {
	// Do stuff with collection.
});

nonogo.editField(key, index, field, value, callback)

Edits a single field. Callback is given two arguments, error and collection.

Example:
nonogo.editField('People', 59, sex, 'female', function(error, collection) {
	// Do stuff with collection.
});

nonogo.deleteKey(key, callback)

Deletes an entire key. Callback is given two arguments, error and collection.

Example:
nonogo.deleteKey('People', function(error, collection) {
	// Do stuff with collection.
});

nonogo.deleteRow(key, index, callback)

Deletes an entire row. Callback is given two arguments, error and collection.

Example:
nonogo.deleteRow('People', 59, function(error, collection) {
	// Do stuff with collection.
});

nonogo.deleteField(key, index, field, callback)

Deletes a single field. Callback is given two arguments, error and collection.

Example:
nonogo.deleteField('People', 59, 'name', function(error, collection) {
	// Do stuff with collection.
});

nonogo.deleteAll(callback)

Deletes entire database. Callback is given one argument, error.

Example:
nonogo.deleteAll(function(error) {
	// Do stuff with collection.
});

nonogo.commit(callback)

Commits changes to the collection object to database file. Callback is given one argument, error.

Example:
nonogo.commit(function(error) {
	// Do stuff with collection.
});