fix(api/utils): fix listquerier
make it so that `author` is an object we can assign to, NOT a number
This commit is contained in:
parent
b4e8894291
commit
c502acbba9
@ -1,19 +1,20 @@
|
||||
import { Band } from "~/models/band";
|
||||
import { Challenge } from "~/models/challenges/gen";
|
||||
import { Story } from "~/models/stories";
|
||||
import { log } from "../logger";
|
||||
|
||||
export default async function (query, context, limit?: number, sort?) {
|
||||
query["chapters.hidden"] = false;
|
||||
if (context.currentUser) {
|
||||
if (!query.author) query.author = {};
|
||||
if (!query["chapters.bands"]) query["chapters.bands"] = {};
|
||||
query["chapters.bands"]["$nin"] = context.currentUser.hidden_bands;
|
||||
query["author"]["$nin"] = context.currentUser.hidden_authors;
|
||||
query["chapters.bands"]["$nin"] = context.currentUser.hiddenBands;
|
||||
query["author"]["$nin"] = context.currentUser.hiddenAuthors;
|
||||
}
|
||||
query["ficmas"] = {
|
||||
$nin: context.ficmasarray_raw.map((a) => a._id),
|
||||
};
|
||||
console.log(query);
|
||||
log.debug(query, { label: "list query" });
|
||||
let stories = await Story.find(query, null)
|
||||
.collation({ locale: "en" })
|
||||
.sort(sort ? sort : { "chapters.posted": -1 })
|
||||
|
Loading…
x
Reference in New Issue
Block a user