slate/node_common/data/methods/get-api-key-by-key.js

27 lines
529 B
JavaScript
Raw Normal View History

import { runQuery } from "~/node_common/data/utilities";
export default async ({ key }) => {
return await runQuery({
label: "GET_API_KEY_BY_KEY",
queryFn: async (DB) => {
2020-08-12 11:34:17 +03:00
const query = await DB.select("*").from("keys").where({ key }).first();
if (!query || query.error) {
return null;
}
if (query.id) {
return query;
}
return null;
},
errorFn: async (e) => {
return {
error: "GET_API_KEY_BY_KEY",
source: e,
};
},
});
};