简体   繁体   中英

Is Node Mongodb Native Driver v 2.2 still compatible with node 0.12.X?

I use the Mongodb Native Driver For Node v2.1 with a node app in 0.12.X version. I've just upgrade the driver to the 2.2 version, but I get this error with a simple insert:

/web-apps/j2ee/jenkins/back/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:320
  self.s.pool = new Pool(Object.assign(self.s.options, options, {bson: this.s.
                                ^
TypeError: undefined is not a function
    at Server.connect (/web-apps/j2ee/jenkins/back/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:320:33)
    at Server.connect (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/server.js:328:17)
    at open (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/db.js:220:19)
    at Db.open (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/db.js:243:44)
    at connectFunction (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/mongo_client.js:220:67)
    at connect (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/mongo_client.js:367:5)
    at Function.MongoClient.connect (/web-apps/j2ee/jenkins/back/node_modules/mongodb/lib/mongo_client.js:113:3)
    at PriceInsert._write (/web-apps/j2ee/jenkins/back/src/helpers/price-insert-stream.js:34:21)
    at doWrite (_stream_writable.js:301:12)
    at writeOrBuffer (_stream_writable.js:288:5)

The documentation for driver compatibility is not to date, as there is only the requirements for the 2.1 version. They seems to use ES2015 features (Object.assign) that is not compatible with node 0.12.X.

Do I have to stay in v 2.1?

I've just found an issue on their Jira tracker, this bug will be fixed in the next release, the 2.2.1.

https://jira.mongodb.org/browse/NODE-747?jql=project%20%3D%20NODE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM