mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-29 20:11:55 +03:00
30 lines
568 B
JavaScript
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,
|
|
};
|
|
},
|
|
});
|
|
};
|