create-orphan

This commit is contained in:
jimmylee 2020-11-16 23:59:11 -08:00
parent 48a93e10bd
commit 36ebf5a823

View File

@ -0,0 +1,24 @@
import { runQuery } from "~/node_common/data/utilities";
export default async ({ data }) => {
return await runQuery({
label: "CREATE_ORPHAN",
queryFn: async (DB) => {
const query = await DB.insert({
created_at: new Date(),
data,
})
.into("orphans")
.returning("*");
const index = query ? query.pop() : null;
return JSON.parse(JSON.stringify(index));
},
errorFn: async (e) => {
return {
error: true,
decorator: "CREATE_ORPHAN",
};
},
});
};