slate/node_common/data/methods/create-slate.js

27 lines
572 B
JavaScript
Raw Normal View History

import { runQuery } from "~/node_common/data/utilities";
export default async ({ slatename, data = {} }) => {
return await runQuery({
label: "CREATE_SLATE",
queryFn: async (DB) => {
const query = await DB.insert({
slatename,
data,
})
.into("slates")
.returning("*");
const index = query ? query.pop() : null;
index.type = "SLATE";
return index;
},
errorFn: async (e) => {
2020-09-28 23:12:43 +03:00
console.log(e);
return {
error: true,
decorator: "CREATE_SLATE",
};
},
});
};