2020-07-25 03:16:35 +03:00
|
|
|
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;
|
2020-08-28 07:34:50 +03:00
|
|
|
index.type = "SLATE";
|
2020-07-25 03:16:35 +03:00
|
|
|
return index;
|
|
|
|
},
|
|
|
|
errorFn: async (e) => {
|
2020-09-28 23:12:43 +03:00
|
|
|
console.log(e);
|
2020-07-25 03:16:35 +03:00
|
|
|
return {
|
2020-09-13 01:08:36 +03:00
|
|
|
error: true,
|
|
|
|
decorator: "CREATE_SLATE",
|
2020-07-25 03:16:35 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|