mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 22:59:01 +02:00
3af7b2da30
Set featuresUpdatedAt GitOrigin-RevId: 87d53e5ff27a8ebce2ba8c7223d498b291d05a23
26 lines
746 B
JavaScript
26 lines
746 B
JavaScript
const { User } = require('../../models/User')
|
|
|
|
module.exports = {
|
|
updateFeatures(userId, features, callback) {
|
|
const conditions = { _id: userId }
|
|
const update = {
|
|
featuresUpdatedAt: new Date(),
|
|
}
|
|
for (const key in features) {
|
|
const value = features[key]
|
|
update[`features.${key}`] = value
|
|
}
|
|
User.updateOne(conditions, update, (err, result) =>
|
|
callback(err, features, (result ? result.nModified : 0) === 1)
|
|
)
|
|
},
|
|
|
|
overrideFeatures(userId, features, callback) {
|
|
const conditions = { _id: userId }
|
|
const update = { features, featuresUpdatedAt: new Date() }
|
|
User.updateOne(conditions, update, (err, result) =>
|
|
callback(err, (result ? result.nModified : 0) === 1)
|
|
)
|
|
},
|
|
}
|