mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-27 02:52:25 +03:00
25 lines
516 B
JavaScript
25 lines
516 B
JavaScript
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;
|
|
return index;
|
|
},
|
|
errorFn: async (e) => {
|
|
return {
|
|
error: "CREATE_SLATE",
|
|
source: e,
|
|
};
|
|
},
|
|
});
|
|
};
|