abstract-nosql
Advanced tools
Comparing version 1.5.0 to 1.5.1
{ | ||
"name": "abstract-nosql", | ||
"description": "An abstract prototype for nosql database(LevelDOWN API)", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ "Riceball LEE <snowyu.lee@gmail.com> (https://github.com/snowyu)", |
@@ -34,3 +34,4 @@ # Abstract NoSQL Database [](http://travis-ci.org/snowyu/node-abstract-nosql) | ||
+ !TODO: Add the stream ability | ||
+ Add the stream ability | ||
* this feature has moved to [nosql-stream](https://snowyu/nosql-stream) package. | ||
+ Add the AbstractError and error code supports. | ||
@@ -106,3 +107,50 @@ * DB constructor allows no location. | ||
# Streamable | ||
see [nosql-stream](https://snowyu/nosql-stream) for more details | ||
```js | ||
var MemDB = require("memdown-sync") | ||
var NoSQLStream = require("nosql-stream") | ||
var ReadStream = NoSQLStream.ReadStream | ||
var WriteStream = NoSQLStream.WriteStream | ||
var db1 = MemDB("db1") | ||
var db2 = MemDB("db2") | ||
var ws = WriteStream(db1) | ||
var ws2 = WriteStream(db2) | ||
ws.on('error', function (err) { | ||
console.log('Oh my!', err) | ||
}) | ||
ws.on('finish', function () { | ||
console.log('Write Stream finish') | ||
//read all data through the ReadStream | ||
ReadStream(db1).on('data', function (data) { | ||
console.log(data.key, '=', data.value) | ||
}) | ||
.on('error', function (err) { | ||
console.log('Oh my!', err) | ||
}) | ||
.on('close', function () { | ||
console.log('Stream closed') | ||
}) | ||
.on('end', function () { | ||
console.log('Stream closed') | ||
}) | ||
.pipe(ws2) //copy Database db1 to db2: | ||
}) | ||
ws.write({ key: 'name', value: 'Yuri Irsenovich Kim' }) | ||
ws.write({ key: 'dob', value: '16 February 1941' }) | ||
ws.write({ key: 'spouse', value: 'Kim Young-sook' }) | ||
ws.write({ key: 'occupation', value: 'Clown' }) | ||
ws.end() | ||
``` | ||
## Example | ||
@@ -109,0 +157,0 @@ |
163950
530