senecajs / seneca-mongo-store

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

quick example error #67

Closed hallywang closed 3 years ago

hallywang commented 6 years ago

seneca.use('mongo-store', {
  uri: 'mongodb://120.0.0.1:27017/dbname'
})
.use("basic")
.use("entity",{mem_store: false})

seneca.ready(function () {
  var apple = seneca.make$('fruit')
  apple.name  = 'Pink Lady'
  apple.price = 0.99
  apple.save$(function (err,apple) {
    console.log( "apple.id = "+apple.id  )
  })
})
davide-talesco commented 6 years ago

The problem seems to be the order of .use, if .use('entity') comes before use('mongo-store') it works.

The below

var seneca = require('seneca')();

seneca.use("entity")
  .use('mongo-store', {
      uri: 'mongodb://localhost:27017/dbname'
  })

seneca.ready(function () {
  var apple = seneca.make$('fruit')
  apple.name  = 'Pink Lady'
  apple.price = 0.99
  apple.save$(function (err,apple) {
    console.log( "apple.id = "+apple.id  )
  })
})
rjrodger commented 3 years ago

update readme to note this

lilsweetcaligula commented 3 years ago

@rjrodger Looks like this issue is already addressed.