Navigation Menu

Skip to content

Commit

Permalink
Open a database in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 14, 2012
1 parent 0717d6f commit addd15c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/wrapped-nroonga.js
Expand Up @@ -34,7 +34,7 @@ function Context(source) {
if (typeof source == 'string') { // path
mkdirp.sync(path.dirname(source));
this._path = source;
this._context = new nroonga.Database(source);
this.open();
} else if (source instanceof nroonga.Database)
this._context = source;
else
Expand Down Expand Up @@ -104,8 +104,14 @@ Context.prototype = {
},

reopen: function() {
this.close();
this.open();
return this;
},

open: function() {
if (!this._path)
throw new Error('cannot reopen');
throw new Error('cannot open');
this._context = new nroonga.Database(this._path);
return this;
}
Expand Down

0 comments on commit addd15c

Please sign in to comment.