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

30 lines
568 B
JavaScript

import { runQuery } from "~/node_common/data/utilities";
export default async ({ slatename }) => {
return await runQuery({
label: "GET_SLATE_BY_NAME",
queryFn: async (DB) => {
const query = await DB.select("*")
.from("slates")
.where({ slatename })
.first();
if (!query || query.error) {
return null;
}
if (query.id) {
return query;
}
return null;
},
errorFn: async (e) => {
return {
error: "GET_SLATE_BY_NAME",
source: e,
};
},
});
};