slate/node_common/data/methods/create-pending-data.js
2020-09-21 16:20:24 -07:00

25 lines
540 B
JavaScript

import { runQuery } from "~/node_common/data/utilities";
export default async ({ data, owner_user_id }) => {
return await runQuery({
label: "CREATE_PENDING_DATA",
queryFn: async (DB) => {
const query = await DB.insert({
data,
owner_user_id,
})
.into("pending")
.returning("*");
const index = query ? query.pop() : null;
return index;
},
errorFn: async (e) => {
return {
error: true,
decorator: "CREATE_PENDING_DATA",
};
},
});
};