Page MenuHomeSealhub

special-filter.ts
No OneTemporary

special-filter.ts

import type { App } from "../app/app.js";
import type Query from "../datastore/query.js";
import type { QueryStage } from "../datastore/query.js";
export default abstract class SpecialFilter {
params: any;
app: App;
collection_name: string;
constructor(collection_name: string, params: any) {
this.params = params;
this.collection_name = collection_name;
}
init(app: App) {
this.app = app;
}
abstract getFilteringQuery(): Promise<Query>;
abstract getNopassReason(): string;
getCollection() {
return this.app.collections[this.collection_name];
}
async checkSingleResource(app: App, resource_id: string) {
const documents = await app.Datastore.aggregate(
this.getCollection().name,
[
{ $match: { id: resource_id } },
...(await this.getFilteringQuery()).toPipeline(),
] as QueryStage[]
);
return documents.length
? SpecialFilter.pass()
: SpecialFilter.nopass(this.getNopassReason());
}
static pass = async () => ({ passed: true });
static nopass = async (reason: string) => ({ passed: false, reason });
}

File Metadata

Mime Type
text/x-java
Expires
Mon, Dec 23, 01:45 (5 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556795
Default Alt Text
special-filter.ts (1 KB)

Event Timeline