mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
c14467b87a
GitOrigin-RevId: c5abb64729530baecbee0eb589eaed39faa2ac56
24 lines
516 B
JavaScript
24 lines
516 B
JavaScript
import { db, ObjectId } from './mongodb.js'
|
|
|
|
export async function touchContact(userId, contactId) {
|
|
await db.contacts.updateOne(
|
|
{ user_id: 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: ObjectId(userId.toString()),
|
|
})
|
|
|
|
return user?.contacts
|
|
}
|