diff --git a/.changeset/purple-dryers-peel.md b/.changeset/purple-dryers-peel.md new file mode 100644 index 000000000..fc385f191 --- /dev/null +++ b/.changeset/purple-dryers-peel.md @@ -0,0 +1,6 @@ +--- +'@accounts/mongo-password': minor +'@accounts/mongo-sessions': minor +--- + +MongoDB 4.X support for Meteor@2.5.1 - Mongo.createUser and Mongo.createSession bugfixes diff --git a/packages/database-mongo-password/src/mongo-password.ts b/packages/database-mongo-password/src/mongo-password.ts index bbf51a3c4..34dd1b7eb 100644 --- a/packages/database-mongo-password/src/mongo-password.ts +++ b/packages/database-mongo-password/src/mongo-password.ts @@ -149,8 +149,9 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword { user._id = this.options.idProvider(); } const ret = await this.userCollection.insertOne(user); + // keep ret.ops for compatibility with MongoDB 3.X, version 4.X uses insertedId - return ((ret.insertedId ?? ret.ops[0]._id) as ObjectID).toString(); + return ((ret.insertedId ? ret.insertedId : ret.ops[0]._id) as ObjectID).toString(); } /** diff --git a/packages/database-mongo-sessions/src/mongo-sessions.ts b/packages/database-mongo-sessions/src/mongo-sessions.ts index 5f61c75d8..9ac7945e5 100644 --- a/packages/database-mongo-sessions/src/mongo-sessions.ts +++ b/packages/database-mongo-sessions/src/mongo-sessions.ts @@ -124,7 +124,8 @@ export class MongoSessions implements DatabaseInterfaceSessions { const ret = await this.sessionCollection.insertOne(session); // keep ret.ops for compatibility with MongoDB 3.X, version 4.X uses insertedId - return ((ret.insertedId ?? ret.ops[0]._id) as ObjectID).toString(); + return ((ret.insertedId ? ret.insertedId : ret.ops[0]._id) as ObjectID).toString(); + } /**