senecajs / seneca-mongo-store

Node.js Seneca data storage plugin for MongoDB
MIT License
35 stars 43 forks source link

seneca mongo store quick sample wont work #77

Closed slashd0t closed 4 years ago

slashd0t commented 4 years ago

I'm using the quick example but it didn't work. My current setup:

node v8.17
seneca 3.22
seneca-basic 0.5
seneca-entity 2.5
seneca-mongo-store 1.5

File: node index.js

const seneca = require('seneca')();
seneca.use('entity');
seneca.use('mongo-store', {
  uri: 'mongodb://localhost:27017/seneca_testdb'
});

seneca.ready(() => {
  var apple = seneca.make$('fruit')
  apple.name = 'Pink Lady'
  apple.price = 0.99
  apple.save$((err,apple) => {
    console.log( "apple.id = "+apple.id  )
  });
});

But when I run this, I got this error:

{
  "kind": "fatal",
  "level": 600,
  "plugin": "seneca",
  "tag": "3.22.0",
  "id": "q1cgduxozeft/1597741532370/15838/3.22.0/-",
  "code": "ready_failed",
  "notice": "seneca: Ready function failed: instance.private$.get_instance is not a function",
  "err": {
    "eraro": true,
    "orig": {},
    "code": "ready_failed",
    "seneca": true,
    "package": "seneca",
    "msg": "seneca: Ready function failed: instance.private$.get_instance is not a function",
    "details": {
      "message": "instance.private$.get_instance is not a function",
      "errmsg": "instance.private$.get_instance is not a function",
      "errline": "at Entity.log (/home/admin/sample_seneca/node_modules/seneca/lib/logging.js:266:36)",
      "orig$": {},
      "message$": "instance.private$.get_instance is not a function"
    },
    "callpoint": "at Entity.log (/home/admin/sample_seneca/node_modules/seneca/lib/logging.js:266:36)",
    "fatal$": true
  },
  "isot": "2020-08-18T09:05:32.867Z",
  "when": 1597741532867,
  "level_name": "fatal",
  "seneca_id": "q1cgduxozeft/1597741532370/15838/3.22.0/-"
}

Any idea on how to resolve this issue? Thanks

slashd0t commented 4 years ago

I was able to solved this issue by using different seneca version 2.0.x. I don't know why seneca 3.0.x won't work in node v8.17.