X-Git-Url: https://git.auder.net/?p=qomet.git;a=blobdiff_plain;f=entities%2Fcourse.js;fp=entities%2Fcourse.js;h=0000000000000000000000000000000000000000;hp=9b3fb46c95e0af3a01537032cea9ffb747f08f0b;hb=43828378be054cf3604b753e8d9ab24af911188f;hpb=7a7dc732599b358b25b770cfc27036f4b403d1b4 diff --git a/entities/course.js b/entities/course.js deleted file mode 100644 index 9b3fb46..0000000 --- a/entities/course.js +++ /dev/null @@ -1,99 +0,0 @@ -const db = require("../utils/database"); - -const CourseEntity = -{ - /* - * Structure: - * _id: BSON id - * uid: prof ID - * code: varchar - * description: varchar - * password: monitoring password hash - * students: array of - * number: student number - * name: varchar - * group: integer - */ - - getByUser: function(uid, callback) - { - db.courses.find( - { uid: uid }, - callback - ); - }, - - getById: function(cid, callback) - { - db.courses.findOne( - { _id: cid }, - callback - ); - }, - - getByPath: function(uid, code, callback) - { - db.courses.findOne( - { - $and: [ - { uid: uid }, - { code: code }, - ] - }, - callback - ); - }, - - insert: function(uid, code, description, cb) - { - db.courses.insert( - { - uid: uid, - code: code, - description: description, - students: [ ], - }, - cb); - }, - - setStudents: function(cid, students, cb) - { - db.courses.update( - { _id: cid }, - { $set: { students: students } }, - cb - ); - }, - - // Note: return { students: { ... } }, pointing on the requested row - getStudent: function(cid, number, cb) - { - db.courses.findOne( - { _id: cid }, - { - _id: 0, - students: { $elemMatch: {number: number} } - }, - cb - ); - }, - - setPassword: function(cid, pwd, cb) - { - db.courses.update( - { _id: cid }, - { $set: { password: pwd } }, - cb - ); - }, - - remove: function(cid, cb) - { - db.courses.remove( - { _id: cid }, - cb - ); - }, -} - -module.exports = CourseEntity;