Closed rkdrepo closed 8 years ago
@rahulkrdas If you remove the mongo plugin, does the code work (it should default to in mem store)
Yes, without mongodb plug in its going to members store.
I found that Quick Example provided in plugin README is not working with newest version of seneca 2.1.0
because part of functionality was moved to seneca-entity
module. I've managed to run example with the following changes:
Install
Need to install seneca-entity
as dependency
npm install seneca-entity
Quick Example
Need to add following line seneca.use('entity');
after defining seneca
. Here's full code:
const seneca = require('seneca')();
seneca.use('entity');
seneca.use('mongo-store', {
name: 'test',
host: '127.0.0.1',
port: 27017
});
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 )
});
});
I can see new entries in Mongo database:
> db['fruit'].find()
{ "_id" : ObjectId("57a44808451caf7013e1326d"), "name" : "Pink Lady", "price" : 0.99 }
Best place to look for samples is the tests. Just merged an updated sample. Sample on how to use entity: https://github.com/senecajs/seneca-mongo-store/blob/master/test/mongo.test.js#L28
Sample on how to disable mem-store: https://github.com/senecajs/seneca-mongo-store/blob/master/test/mongo.test.js#L23
I'll close this. Please open a separate issue if something is not working. Thank you.
works for me as well ..
db['fruit'].find() { "_id" : ObjectId("57aa30f4b117631587a9bfe2"), "name" : "Pink Lady", "price" : 0.99 }
Its working. Thanks for your help @mihaidma .
Yes... putting the seneca.use('entity') after declaring seneca variable works for me. Thanks @luhtonen. This was very helpful.
thanks @luhtonen ! chaining .use('entity) immediately after seneca fixed this for me too (when running mongo-store)
For me this only worked after also adding seneca.use('basic')
Always mongo-store at last plugin..
I was exploring seneca-mongo-store with the example provided and I realize that its storing data into memory. How do I force it to write into mongo.
Code I am using:
Also I tried to add {default_plugins: {'mem-store':false}} but it generates error.