DerbyJS - 无法让Mongo存储工作

时间:2013-01-12 10:41:57

标签: javascript node.js mongodb derbyjs

我一直在和德比开玩笑一段时间,目前我正在尝试围绕整个赛车存储事件。虽然我喜欢在客户端没有硬编码任何MongoDB查询的想法,但我不能完全解决所有问题。

我反复收到Error: No persistence handler for set(meta,[object Object],1)条消息,现在尝试将其归结为最小的例子。这是我server/index.js的相关部分:

var http = require('http')
  , path = require('path')
  , express = require('express')
  , gzippo = require('gzippo')
  , derby = require('derby')
  , api = require('../api')
  , app = require('../app')
  , serverError = require('./serverError')


// SERVER CONFIGURATION //

var expressApp = express();
var server = module.exports = http.createServer(expressApp);

derby.use(derby.logPlugin);


// Setting up MongoDB storage
derby.use(require('racer-db-mongo'));
var store = derby.createStore({
  listen:  server
  , db: {
      type: 'Mongo'
    , uri: 'mongodb://localhost/webIsoRogue'
  }
});

// Trying to insert some dummy data
var model = store.createModel();
model.set('meta', {
  app: {
    title: 'Hi there'
  , author: 'Erik Mathers'
  }
});

console.log(model.get('meta.app'));

我已多次验证MongoDB服务器正在运行且可访问,它是!

一旦我尝试存储虚拟数据,我就会收到不太有用的错误消息:Error: No persistence handler for set(meta,[object Object],1)

有谁能告诉我哪里出错了?

1 个答案:

答案 0 :(得分:0)

尝试:'mongodb://localhost:27017/webIsoRogue'