feat: allow exists methods to work with arrays and single id

This commit is contained in:
Barış Soner Uşaklı
2021-03-31 13:20:35 -04:00
parent d16b45fd2d
commit 285aa36556
4 changed files with 17 additions and 13 deletions

View File

@@ -35,8 +35,10 @@ require('./bookmarks')(Topics);
require('./merge')(Topics);
Topics.events = require('./events');
Topics.exists = async function (tid) {
return await db.exists(`topic:${tid}`);
Topics.exists = async function (tids) {
return await db.exists(
Array.isArray(tids) ? tids.map(tid => `topic:${tid}`) : `topic:${tids}`
);
};
Topics.getTopicsFromSet = async function (set, uid, start, stop) {