2020-08-26 00:23:45 +03:00
|
|
|
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;
|
2020-08-28 07:34:50 +03:00
|
|
|
index.type = "ACTIVITY";
|
2020-08-26 00:23:45 +03:00
|
|
|
return JSON.parse(JSON.stringify(index));
|
|
|
|
},
|
|
|
|
errorFn: async (e) => {
|
|
|
|
return {
|
2020-09-13 01:08:36 +03:00
|
|
|
error: true,
|
|
|
|
decorator: "CREATE_ACTIVITY",
|
2020-08-26 00:23:45 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|