sailsjs更改为mongodb后仍使用默认数据库 [英] sailsjs still uses default database after changing it to mongodb

查看:73
本文介绍了sailsjs更改为mongodb后仍使用默认数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Sailsjs的新手,目前正在从事使用sailsjs的项目.我想将默认数据库更改为mongodb.我在config/local.js中做到了,就像下面

I am new to sailsjs and currently working on project that uses sailsjs. I want to change the default database to mongodb. I did it in config/local.js like following

connections: {
    'defaults': 'mongo',
    mongo: {
       module: 'sails-mongo',
       host: 'localhost',
       user: '',
       password: '',
       database: 'dbName',
       schema: true
    }
}

启动mongodb并尝试使用application(我正在处理的)创建一些数据之后,然后当我使用mongodb command line toolmongodb中对其进行检查时.它在那里找不到任何数据,当我在应用程序中检查它是否从数据库加载了所有数据时.这意味着它仍在使用默认数据库存储该数据.

After starting mongodb and tried to create some data using application(that I am working on), and then when I check that in mongodb using mongodb command line tool. It finds no data there and when I check that in application it loads all of the data from database. That means it is still using the default database where that data is stored.

我正在使用sailsjs版本0.11.0.

I am using sailsjs version 0.11.0.

推荐答案

多个命名适配器可能存在一些问题.

There can be some issues with multiple named adapters.

如果您的问题是将开发人员和生产人员分开,则最好用不同的名称(aka MongoDev,MongoProd)来完全命名所有名称,但您所有的连接和默认模型参数 配置/环境/ -production.js -development.js

It's best to completely name everything differently (aka MongoDev, MongoProd) and if your issue is separating dev and production, but all your connection and default model params in the config/env/ - production.js - development.js

您应该查看以下链接

https://github.com/balderdashy/sails/issues/939

在Sails.js中处理数据库环境配置

这篇关于sailsjs更改为mongodb后仍使用默认数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆