mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
692 B
42 lines
692 B
6 years ago
|
'use strict';
|
||
|
|
||
|
const Mongo = require(__dirname+'/../helpers/db.js')
|
||
|
, db = Mongo.client.db('boards');
|
||
|
|
||
|
module.exports = {
|
||
|
|
||
|
db,
|
||
|
|
||
|
findOne: async (name) => {
|
||
|
return db.collection('boards').findOne({ '_id': name });
|
||
|
},
|
||
|
|
||
|
insertOne: async (data) => {
|
||
|
return db.collection('boards').insertOne(data);
|
||
|
},
|
||
|
|
||
|
deleteOne: async (board, options) => {
|
||
|
|
||
|
},
|
||
|
|
||
|
deleteMany: async (board, options) => {
|
||
|
|
||
|
},
|
||
|
|
||
|
deleteAll: async (board) => {
|
||
|
return db.collection('boards').deleteMany({});
|
||
|
},
|
||
|
|
||
|
exists: async (req, res, next) => {
|
||
|
|
||
|
const board = await module.exports.findOne(req.params.board)
|
||
|
if (!board) {
|
||
|
return res.status(404).render('404')
|
||
|
}
|
||
|
res.locals.board = board;
|
||
|
next();
|
||
|
|
||
|
},
|
||
|
|
||
|
}
|