mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
36 lines
993 B
JavaScript
36 lines
993 B
JavaScript
|
/* eslint-disable
|
||
|
camelcase,
|
||
|
handle-callback-err,
|
||
|
max-len,
|
||
|
*/
|
||
|
// TODO: This file was created by bulk-decaffeinate.
|
||
|
// Fix any style issues and re-enable lint.
|
||
|
/*
|
||
|
* decaffeinate suggestions:
|
||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||
|
* DS207: Consider shorter variations of null checks
|
||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||
|
*/
|
||
|
const { User } = require('../../models/User')
|
||
|
|
||
|
module.exports = {
|
||
|
updateFeatures(user_id, features, callback) {
|
||
|
if (callback == null) {
|
||
|
callback = function(err, features, featuresChanged) {}
|
||
|
}
|
||
|
const conditions = { _id: user_id }
|
||
|
const update = {}
|
||
|
for (let key in features) {
|
||
|
const value = features[key]
|
||
|
update[`features.${key}`] = value
|
||
|
}
|
||
|
return User.update(conditions, update, (err, result) =>
|
||
|
callback(
|
||
|
err,
|
||
|
features,
|
||
|
(result != null ? result.nModified : undefined) === 1
|
||
|
)
|
||
|
)
|
||
|
}
|
||
|
}
|