mirror of https://gitgud.io/fatchan/jschan.git
parent
8c858ba018
commit
f92adeb610
7 changed files with 75 additions and 27 deletions
@ -0,0 +1,41 @@ |
|||||||
|
'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(); |
||||||
|
|
||||||
|
}, |
||||||
|
|
||||||
|
} |
@ -1,9 +1,10 @@ |
|||||||
mixin post(board, post) |
mixin post(board, post) |
||||||
.post-container |
.post-container |
||||||
if post.thread == null |
if post.thread == null |
||||||
a(href=`/${board}/thread/${post._id}`) #{post._id} |
a(href=`/${board._id}/thread/${post._id}`) #{post._id} |
||||||
else |
else |
||||||
a(href=`/${board}/thread/${post.thread}#${post._id}`) #{post._id} |
a(href=`/${board._id}/thread/${post.thread}#${post._id}`) #{post._id} |
||||||
span , #{post.author} |
span , #{post.author} |
||||||
span , #{post.date} |
span , #{post.date} |
||||||
|
p #{post.title} |
||||||
p #{post.content} |
p #{post.content} |
||||||
|
Loading…
Reference in new issue