1

I've installed sails-mongo through npm and have a basic sails.js application running but it's not recognizing my host.

MongoDB is up and running on the default port 27017 but after I generate a model I get this error when trying to run the application: enter image description here

Here is my adapter.js, I'm running node v0.10.0 and sails v0.8.895

// Configure installed adapters
// If you define an attribute in your model definition, 
// it will override anything from this global config.
module.exports.adapters = {

    // If you leave the adapter config unspecified 
    // in a model definition, 'default' will be used.
    'default': 'mongo',

    // In-memory adapter for DEVELOPMENT ONLY
    // (data is NOT preserved when the server shuts down)
    memory: {
        module: 'sails-dirty',
        inMemory: true
    },

    // Persistent adapter for DEVELOPMENT ONLY
    // (data IS preserved when the server shuts down)
    // PLEASE NOTE: disk adapter not compatible with node v0.10.0 currently 
    //              because of limitations in node-dirty
    //              See https://github.com/felixge/node-dirty/issues/34
    // disk: {
    //  module: 'sails-dirty',
    //  filePath: './.tmp/dirty.db',
    //  inMemory: false
    // },

     mongo: {
        module   : 'sails-mongo',
        url      : 'mongodb://Chris:DBPASSWORD@localhost:27017/localHostTestDB'
      }
};

I've already added the user to the localHostTestDB with role of admin.

Any help would be appreciate. Thanks!

4

2 回答 2

1

最终不得不将sails.js 更新到0.9.3 版并使用sails-mongo 适配器:

module.exports.adapters = {

  // If you leave the adapter config unspecified 
  // in a model definition, 'default' will be used.
  'default': 'mongo',

  mongo: {
    module   : 'sails-mongo',
    host     : 'localhost',
    user     : 'Chris',
    password : 'PASSWORD',
    database : 'localHostTestDB'
  },

  // In-memory adapter for DEVELOPMENT ONLY
  memory: {
    module: 'sails-memory'
  },

  // Persistent adapter for DEVELOPMENT ONLY
  // (data IS preserved when the server shuts down)
  disk: {
    module: 'sails-disk'
  },

  // // MySQL is the world's most popular relational database.
  // // Learn more: http://en.wikipedia.org/wiki/MySQL
  // mysql: {
  //   module: 'sails-mysql',
  //   host: 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS',
  //   user: 'YOUR_MYSQL_USER',
  //   password: 'YOUR_MYSQL_PASSWORD',
  //   database: 'YOUR_MYSQL_DB'
  // }
};
于 2013-07-23T17:54:40.973 回答
0

从 NPM 安装。将 mongo 配置添加到 config/adapters.js 文件中。访问http://sailsjs.org

于 2013-07-23T17:57:01.860 回答