mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-18 14:31:44 +03:00
26 lines
598 B
JavaScript
26 lines
598 B
JavaScript
|
import { runQuery } from "~/node_common/data/utilities";
|
||
|
|
||
|
export default async ({ slateId, userId, data }) => {
|
||
|
return await runQuery({
|
||
|
label: "CREATE_ACTIVITY",
|
||
|
queryFn: async (DB) => {
|
||
|
const query = await DB.insert({
|
||
|
owner_slate_id: slateId,
|
||
|
owner_user_id: userId,
|
||
|
data,
|
||
|
})
|
||
|
.into("activity")
|
||
|
.returning("*");
|
||
|
|
||
|
const index = query ? query.pop() : null;
|
||
|
return JSON.parse(JSON.stringify(index));
|
||
|
},
|
||
|
errorFn: async (e) => {
|
||
|
return {
|
||
|
error: "CREATE_ACTIVITY",
|
||
|
source: e,
|
||
|
};
|
||
|
},
|
||
|
});
|
||
|
};
|