Merge pull request #15331 from overleaf/csh-issue-11625-mongo-ug-5-contacts

Upgrade mongodb module for contacts from 4.12.1 to 6.1.0

GitOrigin-RevId: 22c4544b21363d82dcf3215c660e4412bb179fe8
This commit is contained in:
Christopher Hoskin
2023-10-24 08:03:11 +00:00
committed by Copybot
parent 0572535a7e
commit 6a118d9439
5 changed files with 90 additions and 77 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { db, ObjectId } from './mongodb.js'
export async function touchContact(userId, contactId) {
await db.contacts.updateOne(
{ user_id: ObjectId(userId.toString()) },
{ user_id: new ObjectId(userId.toString()) },
{
$inc: {
[`contacts.${contactId}.n`]: 1,
@@ -17,7 +17,7 @@ export async function touchContact(userId, contactId) {
export async function getContacts(userId) {
const user = await db.contacts.findOne({
user_id: ObjectId(userId.toString()),
user_id: new ObjectId(userId.toString()),
})
return user?.contacts
+1 -1
View File
@@ -24,7 +24,7 @@
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.18.2",
"mongodb": "^4.12.1",
"mongodb": "^6.1.0",
"request": "~2.88.2",
"underscore": "~1.13.1"
},
@@ -22,7 +22,7 @@ describe('Getting Contacts', function () {
describe('with no contacts', function () {
beforeEach(function () {
this.user_id = ObjectId().toString()
this.user_id = new ObjectId().toString()
})
it('should return an empty array', function (done) {
@@ -46,10 +46,10 @@ describe('Getting Contacts', function () {
describe('with contacts', function () {
beforeEach(function (done) {
this.user_id = ObjectId().toString()
this.contact_id_1 = ObjectId().toString()
this.contact_id_2 = ObjectId().toString()
this.contact_id_3 = ObjectId().toString()
this.user_id = new ObjectId().toString()
this.contact_id_1 = new ObjectId().toString()
this.contact_id_2 = new ObjectId().toString()
this.contact_id_3 = new ObjectId().toString()
const touchContact = (userId, contactId, cb) =>
request(
@@ -16,8 +16,8 @@ describe('ContactManager', function () {
},
})
this.user_id = ObjectId().toString()
this.contact_id = ObjectId().toString()
this.user_id = new ObjectId().toString()
this.contact_id = new ObjectId().toString()
})
afterEach(function () {
@@ -62,7 +62,7 @@ describe('ContactManager', function () {
this.contact_id
)
).to.be.rejectedWith(
'Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'
'input must be a 24 character hex string, 12 byte Uint8Array, or an integer'
)
})
})