loopbackio / loopback-connector-mongodb

The official MongoDB connector for the LoopBack framework.
https://loopback.io/doc/en/lb4/MongoDB-connector
Other
187 stars 236 forks source link

mongodb driver 4.x support for Mongo Altas Serverless #638

Open apocist opened 3 years ago

apocist commented 3 years ago

Suggestion

I suggest updating the dependency for MongoDB nodejs driver ^4.1.0

Use Cases

The latest MongoDB driver allow access to MongoDB Altas cloud infrastructure and loadBalanced databases. Connection to this atlas service is impossible with the 3.x series at this time.

Examples

https://github.com/mongodb/node-mongodb-native/blob/4.0/docs/CHANGES_4.0.0.md https://github.com/mongodb/node-mongodb-native/releases/tag/v4.1.0

Acceptance criteria

TBD - will be filled by the team.

dhmlau commented 3 years ago

@apocist, thanks for your suggestion. Would you like to submit a PR?

CNSKnight commented 3 years ago

+1 add on a complete refactor of the ogre that is https://github.com/loopbackio/loopback-connector-mongodb

mongoDBCloudIsHot

apocist commented 3 years ago

I've already actually made a working version for some projects at https://github.com/Sitetheory/loopback-connector-mongodb/tree/mongodb-driver-4.x that can be tested via npmjs with @sitetheory/loopback-connector-mongodb

full tests aren't complete and will break 3.x compatibility (due to driver changes), but I can make a PR now if wanted (can do so in morns)

arsa-dev commented 2 years ago

I've checked the version from @apocist and it is working properly as expected with mongodb driver 4.x, I also have checked PR https://github.com/loopbackio/loopback-connector-mongodb/pull/639 that has been closed by the stale bot.

Don't know the exact reason but since I don't know @apocist availability to reopen it I'm going to open a new one between today/tomorrow with his changes so we can continue discussion and implement anything required to make the official connector running with driver version 4.x, required as mentioned to use MongoDB Atlas connections and loadBalance option.

apocist commented 2 years ago

I've since stopped maintenance on the #639 changes as we've moved away from using Mongo Altas Serverless due to some limitations, but it's usages still seems effective with mongodb ^4.1.0

arsa-dev commented 2 years ago

One day later than expected, but I've finally created promised pull request #672 with only one pending to check test, failing due to bson.ObjectId upgrade that cause object instances to be indetectable to lodash isEmpty function.

This generates a new unwanted behaviour on model relationships when filtering by only one resulting id property instance after intersect possible ids and where filter one(s). Since ObjectId instances are now indetectable to isEmpty function current loopback-datasource-juggler repo logic assumes that is not needed to send query to connector since at his eyes cannot be a result so immediately fire callback with empty result.