mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-28 11:32:46 +03:00
32 lines
583 B
JavaScript
32 lines
583 B
JavaScript
|
import { runQuery } from "~/node_common/data/utilities";
|
||
|
|
||
|
export default async ({ key }) => {
|
||
|
return await runQuery({
|
||
|
label: "GET_API_KEY_BY_KEY",
|
||
|
queryFn: async (DB) => {
|
||
|
const query = await DB.select("*")
|
||
|
.from("keys")
|
||
|
.where({ key })
|
||
|
.first();
|
||
|
|
||
|
console.log(query);
|
||
|
|
||
|
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,
|
||
|
};
|
||
|
},
|
||
|
});
|
||
|
};
|