start to work on new functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -62,6 +62,9 @@ exports.artists = artists;
|
||||
const boxes = require("./boxes");
|
||||
exports.boxes = boxes;
|
||||
|
||||
const progress = require("./progress");
|
||||
exports.progress = progress;
|
||||
|
||||
const videos = require("./videos");
|
||||
exports.videos = videos;
|
||||
|
||||
|
||||
27
services/database/progress.js
Normal file
27
services/database/progress.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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), id: item.id }, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user