mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 20:52:02 +00:00
6a118d9439
Upgrade mongodb module for contacts from 4.12.1 to 6.1.0 GitOrigin-RevId: 22c4544b21363d82dcf3215c660e4412bb179fe8
24 lines
524 B
JavaScript
24 lines
524 B
JavaScript
import { db, ObjectId } from './mongodb.js'
|
|
|
|
export async function touchContact(userId, contactId) {
|
|
await db.contacts.updateOne(
|
|
{ user_id: new ObjectId(userId.toString()) },
|
|
{
|
|
$inc: {
|
|
[`contacts.${contactId}.n`]: 1,
|
|
},
|
|
$set: {
|
|
[`contacts.${contactId}.ts`]: new Date(),
|
|
},
|
|
},
|
|
{ upsert: true }
|
|
)
|
|
}
|
|
|
|
export async function getContacts(userId) {
|
|
const user = await db.contacts.findOne({
|
|
user_id: new ObjectId(userId.toString()),
|
|
})
|
|
|
|
return user?.contacts
|
|
}
|