123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- const level = require('level');
- const sub = require('level-sublevel');
- const search = require('level-search');
- const database = {
- init: function(){
- this.db = sub(level("./mydb", {valueEncoding: 'json'}));
- this.index = search(db, 'search');
- },
- open: function(callback){
- return this.db.open(callback);
- },
- close: function(callback){
- return this.db.close(callback);
- },
- put: function(key, value, options, callback){
- return this.db.put(key, value, options, callback);
- },
- get: function(key, options, callback){
- return this.db.get(key, options, callback);
- },
- del: function(key, options, callback){
- return this.db.del(key, options, callback);
- },
- batch: function(array, options, callback){
- return this.db.batch(array, options, callback);
- },
- isOpen: function(){
- return this.db.isOpen();
- },
- isClosed: function(){
- return this.db.isClosed();
- },
- createReadStream: function(options){
- return this.db.createReadStream(options);
- },
- createKeyStream: function(options){
- return this.db.createKeyStream(options);
- },
- createValueStream: function(options){
- return this.db.createValueStream(options);
- }
- };
- module.exports = database;
|