mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-23 22:12:19 +03:00
create-orphan
This commit is contained in:
parent
48a93e10bd
commit
36ebf5a823
24
node_common/data/methods/create-orphan.js
Normal file
24
node_common/data/methods/create-orphan.js
Normal 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",
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user