Skip to content

MongoDB 4.4 compatibility problems #642

Open
@oduranW

Description

@oduranW

With MongoDB 4.4 Path Collision Restrictions were introduced (https://docs.mongodb.com/manual/release-notes/4.4-compatibility/#path-collision-restrictions), as a result some queries do not work using this connector anymore.

Steps to reproduce

We are running a nodejs app over loopback3 that is using this connector to connect to a MongoDB 4.2 atlas cluster.

Package versions:

"loopback": "3.28.0",
"loopback-connector-mongodb": "5.5.0",

Considering dataModel as an object with:

data : {
     id: 1,
     total: {
        day: [1,2,3],
        month: [4,5,6],
        year: [7,8,9]
     }
}

The following query will result in a path collision error:
data = await this.dataModel.findById({ id: this.Id, filter: { fields: ['total', 'total.month'] } });

And if you update the syntax to follow the MongoDB 4.4 requirements, the query returns an empty object:
data = await this.dataModel.findById({ id: Id, filter: { fields: ['total.month'] } });

Current Behavior

When using the syntax that MongoDB needs in version 4.4 the response comes with no data, and if you try to use the old syntax mongoDB will reject the query with a path collision error.

Expected Behavior

This query should return data since when it is done directly to MongoDB without using the connector it works
data = await this.dataModel.findById({ id: this.Id, filter: { fields: ['total.month'] } });

data should store the object:
{total.month : [4,5,6]}

Additional information

I do not know if this is intended or the connector only supports MongoDB 4.2 or lower versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions