slate/node_common/data/methods/get-slate-by-id.js

30 lines
578 B
JavaScript
Raw Normal View History

import { runQuery } from "~/node_common/data/utilities";
2020-07-26 09:42:22 +03:00
export default async ({ id }) => {
return await runQuery({
label: "GET_SLATE_BY_ID",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("slates")
.where({ id })
.first();
if (!query || query.error) {
return null;
}
if (query.id) {
return JSON.parse(JSON.stringify(query));
}
return null;
},
errorFn: async (e) => {
return {
error: "GET_SLATE_BY_ID",
source: e,
};
},
});
};