mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-30 20:52:29 +01:00
20 lines
492 B
JavaScript
20 lines
492 B
JavaScript
import { MongoClient as mongo } from 'mongodb';
|
|
import config from '../config';
|
|
|
|
module.exports.updateUser = (_id, path, value) => {
|
|
mongo.connect(config.NODE_DB_URI, (err, db) => {
|
|
if (err) throw err;
|
|
|
|
let collection = db.collection('users');
|
|
collection.updateOne(
|
|
{ _id },
|
|
{ $set: { [`${path}`]: value } },
|
|
(updateErr, result) => {
|
|
if (updateErr) throw updateErr;
|
|
console.log('done updating', _id);
|
|
db.close();
|
|
}
|
|
);
|
|
});
|
|
}
|