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