Skip to content
Browse files

bugfix with the root path and setItem id check

  • Loading branch information...
1 parent 5cde476 commit cd29cde3d400daabc003c3f10f9fa9b55d4f5e7f Markus Tiefenbacher committed
Showing with 5 additions and 5 deletions.
  1. +4 −4 app.js
  2. +1 −1 package.json
View
8 app.js
@@ -10,7 +10,7 @@ var async = require('async');
exports.initdb = function(pathname, callback) {
callback = callback || function() {};
- dbpath = __dirname + (pathname || dbpath);
+ dbpath = (path.dirname(process.mainModule.filename) || __dirname) + (pathname || dbpath);
fs.exists(dbpath, function (exists) {
if(exists) {
initialized = true;
@@ -88,12 +88,13 @@ var async = require('async');
data = (typeof data === 'function') ? undefined : data;
callback = callback || function() {};
+ var database = id.replace(/(.*)\/(.*)/gm, '$1');
+ id = String(id.replace(/(.*)\/(.*)/gm, '$2'));
+
if(!database || !id) {
return callback(true, 'Please define database and key e.g. (database/key)');
}
- var database = id.replace(/(.*)\/(.*)/gm, '$1');
- id = String(id.replace(/(.*)\/(.*)/gm, '$2'));
data = data || {};
data._id = id;
data.timestamp = new Date();
@@ -242,4 +243,3 @@ var async = require('async');
};
})(module.exports);
-
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "staticstore",
- "version": "0.0.1",
+ "version": "0.0.2",
"author": "Markus Tiefenbacher <markus.tiefenbacher@gmail.com>",
"description": "key/value database who use static json files as store",
"main": "app.js",

0 comments on commit cd29cde

Please sign in to comment.
Something went wrong with that request. Please try again.