Navigation Menu

Skip to content

Commit

Permalink
Register table plugin after the database created
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 14, 2012
1 parent addd15c commit 74cb150
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/wrapped-nroonga.js
Expand Up @@ -112,8 +112,20 @@ Context.prototype = {
open: function() {
if (!this._path)
throw new Error('cannot open');
this._context = new nroonga.Database(this._path);

try {
// try in open only mode
this._context = new nroonga.Database(this._path, true);
} catch (error) {
// try to create database
this._context = new nroonga.Database(this._path);
this.registerTablePlugin();
}
return this;
},

registerTablePlugin: function() {
this.commandSync('register "table/table"');
}
};

Expand Down

0 comments on commit 74cb150

Please sign in to comment.