overleaf/services/web/app/src/Features/Subscription/UserFeaturesUpdater.js

24 lines
670 B
JavaScript
Raw Normal View History

const { User } = require('../../models/User')
module.exports = {
updateFeatures(userId, features, callback) {
const conditions = { _id: userId }
const update = {}
for (let 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 }
User.updateOne(conditions, update, (err, result) =>
callback(err, (result ? result.nModified : 0) === 1)
)
}
}