Node.js NodeJS i18next和MongoDB
任何人都可以在需要mongodb身份验证时使用i18next node mongodb后端模块。该模块的文档说明如下:Node.js NodeJS i18next和MongoDB,node.js,mongodb,express,i18next,Node.js,Mongodb,Express,I18next,任何人都可以在需要mongodb身份验证时使用i18next node mongodb后端模块。该模块的文档说明如下: var i18next = require('i18next'); var Backend = require('i18next-node-mongodb-backend'); i18next .use(Backend) .init({ backend: options }); 我使用了主机、端口、数据库和收集选项。但是,是否也可以指定用户和密码 i18
var i18next = require('i18next');
var Backend = require('i18next-node-mongodb-backend');
i18next
.use(Backend)
.init({
backend: options
});
我使用了主机、端口、数据库和收集选项。但是,是否也可以指定用户和密码
i18next
.use(mongoBackend)
.use(i18nextMiddleware.LanguageDetector)
.init({
backend: {
host: 'localhost',
port: 27017,
db: 'my_database',
collection: 'my_collection',
// authentication option?
感谢您的回答。通过查看i18next node mongodb后端的代码,我可以确认上述评论。解决这个问题的唯一方法是使用uri参数=> uri的组成应如下所示:
您可以尝试使用uri选项,而不是单独使用主机、端口和数据库:
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]