Upsert the scanCache rather than inserting

pull/42/head
Skyler Grey 3 years ago
parent 62da9bfafc
commit cf89d4c98e
Signed by: Minion3665
GPG Key ID: 1AFD10256B3C714D

@ -606,9 +606,10 @@ export class ScanCache {
} }
async write(hash: string, type: "nsfw" | "malware" | "bad_link", data: boolean, tags?: string[]) { async write(hash: string, type: "nsfw" | "malware" | "bad_link", data: boolean, tags?: string[]) {
await this.scanCache.insertOne( await this.scanCache.updateOne(
{ hash: hash },
{ hash: hash, [type]: data, tags: tags ?? [], addedAt: new Date() }, { hash: hash, [type]: data, tags: tags ?? [], addedAt: new Date() },
collectionOptions Object.assign({ upsert: true }, collectionOptions)
); );
} }

Loading…
Cancel
Save