server/services/database/progress.js
Artem Anufrij 85367e844d
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
api for deleting progress
2023-09-19 15:00:25 +02:00

27 lines
759 B
JavaScript

const { ObjectId } = require('mongodb');
const connector = require("./CONNECTOR");
var dbo;
connector.connect().then((ret) => {
dbo = ret;
});
exports.get = function (parentId, callback) {
dbo.collection("progress")
.findOne({ parentId: parentId }, (err, result) => {
if (err) throw err;
callback(result);
});
}
exports.update = function (item) {
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), parentId: item.parentId }, () => {
dbo.collection("progress").insertOne(item, (err) => {
if (err) throw err;
});
});
};
exports.delete = function (item) {
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), parentId: item.parentId }, (err) => {
if (err) throw err;
});
}