mongodb警告每个操作

时间:2019-03-05 03:14:34

标签: node.js mongodb warnings

我正在使用mongodb官方驱动程序:http://mongodb.github.io/node-mongodb-native/3.1/(是,我正在使用最新版本)

每次操作时我都会收到以下警告:

the options [0] is not supported
the options [1] is not supported
the options [2] is not supported
the options [3] is not supported
the options [4] is not supported
the options [servers] is not supported
the options [caseTranslate] is not supported
the options [username] is not supported
the server/replset/mongos/db options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,keepAliveInitialDelay,connectTimeoutMS,family,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,checkServerIdentity,validateOptions,appname,auth,user,password,authMechanism,compression,fsync,readPreferenceTags,numberOfRetries,auto_reconnect,minSize,monitorCommands,retryWrites,useNewUrlParser]

发生操作的地方

const Config = require('../configurations/database');

// Create a new MongoClient
const MongoClient = require('mongodb').MongoClient;
const Client = new MongoClient(
    Config.PROTOCOL + '://' + Config.USER + ':' + Config.PASSWORD + '@' + Config.HOST +
    '/' + Config.DB,
    {useNewUrlParser: true, retryWrites: true}
);

module.exports = (collection, callback) => {
    // Use connect method to connect to the Server
    Client.connect(() => {
        let Db = Client.db(Config.DB);
        callback(Db.collection(collection));
        Client.close();
    });
};

配置(MongoDB Atlas):

{
    "PROTOCOL": "mongodb+srv",
    "HOST": "cluster0-pdrsu.mongodb.net",
    "DATABASE": "******",
    "USER": "*****",
    "PASSWORD": "****"
}

可以隐藏它吗?有解决办法吗?

0 个答案:

没有答案