Ivshti / linvodb3

Persistent database for Node.js/NW.js/Electron with MongoDB/Mongoose-like features and interface on top of LevelUp
MIT License
747 stars 71 forks source link

[bug] Basic example - NPM version issue #100

Open Granipouss opened 6 years ago

Granipouss commented 6 years ago

Hi,

I had a lot of issues setting up the librairy so I tested ou the basic example.

var LinvoDB = require("linvodb3");

// The following two lines are very important
// Initialize the default store to Medeadown - which is a JS-only store which will work without recompiling in NW.js / Electron
LinvoDB.defaults.store = { db: require("medeadown") }; // Comment out to use LevelDB instead of Medea
// Set dbPath - this should be done explicitly and will be the dir where each model's store is saved
LinvoDB.dbPath = process.cwd();

var Doc = new LinvoDB("doc", { /* schema, can be empty */ })

var d = new Doc();

d.name = "test";
d.saved = new Date();

d.save(function() {
    console.log("saved document with _id: " + d._id);
    Doc.count({},function(err, n) {
        console.log("document count "+n)
    });
});

with the following package.json

{
  "dependencies": {
    "linvodb3": "^3.25.2",
    "medeadown": "^1.1.9"
  }
}

And I have the following error:

.\node_modules\levelup\lib\levelup.js:53
    throw error
    ^
InitializationError: First argument must be an abstract-leveldown compliant store
    at new LevelUP (.\node_modules\levelup\lib\levelup.js:49:13)
    at LevelUP (.\node_modules\levelup\lib\levelup.js:33:12)
    at Function.Model.initStore (.\node_modules\linvodb3\lib\model.js:79:100)
    at new Model (.\node_modules\linvodb3\lib\model.js:52:35)
    at Object.<anonymous> (.\index.js:9:11)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

What am I doing wrong ?

Granipouss commented 6 years ago

Apparently the version that I downloaded from NPM (the 3.25.2) does not have the same code as in the repo. It does not use encode-down for instance. It works fine when I download for the git reposotory

Ivshti commented 6 years ago

The published version is currently broken, as you've already discovered

try this branch: https://github.com/Ivshti/linvodb3/pull/95

I will merge and publish shortly