Files
habitica/debug-scripts/_helper.js
2016-03-15 12:47:24 -05:00

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();
}
);
});
}