mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-25 19:55:26 +03:00
36 lines
851 B
JavaScript
36 lines
851 B
JavaScript
import * as Data from "~/node_common/data";
|
|
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
export default async ({ slateId, ids }) => {
|
|
return await runQuery({
|
|
label: "DELETE_SLATE_FILES",
|
|
queryFn: async (DB) => {
|
|
const slateFiles = await DB("slate_files")
|
|
.where("slateId", slateId)
|
|
.whereIn("fileId", ids)
|
|
.del()
|
|
.returning("*");
|
|
|
|
for (let id of ids) {
|
|
await Data.updateFileTags({ fileId: id });
|
|
}
|
|
|
|
const activityQuery = await DB("activity")
|
|
.where({ slateId, type: "CREATE_SLATE_OBJECT" })
|
|
.whereIn("fileId", ids)
|
|
.del();
|
|
|
|
await Data.recalcSlateFilecount({ slateId });
|
|
|
|
return slateFiles;
|
|
},
|
|
errorFn: async (e) => {
|
|
return {
|
|
error: true,
|
|
decorator: "DELETE_SLATE_FILES",
|
|
};
|
|
},
|
|
});
|
|
};
|