anything-llm/server/utils/files/purgeDocument.js
Timothy Carambat 60a00843df
add ability to purge document from custom documents as well as cleanup its associated cache file (#113)
* add ability to purge document from custom documents as well as cleanup its assoicated cache file

* update alert text
2023-06-26 17:20:09 -07:00

18 lines
501 B
JavaScript

const { purgeVectorCache, purgeSourceDocument } = require(".");
const { Document } = require("../../models/documents");
const { Workspace } = require("../../models/workspace");
async function purgeDocument(filename, meta) {
const workspaces = await Workspace.where();
for (const workspace of workspaces) {
await Document.removeDocuments(workspace, [filename]);
}
await purgeVectorCache(filename);
await purgeSourceDocument(filename);
return;
}
module.exports = {
purgeDocument,
};