2020-07-28 09:54:15 +03:00
|
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
|
|
|
|
export default async ({ userId }) => {
|
|
|
|
return await runQuery({
|
|
|
|
label: "GET_API_KEYS_BY_USER_ID",
|
|
|
|
queryFn: async (DB) => {
|
|
|
|
const query = await DB.select("*")
|
|
|
|
.from("keys")
|
|
|
|
.where({ owner_id: userId });
|
|
|
|
|
|
|
|
if (!query || query.error) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-08-25 09:46:02 +03:00
|
|
|
return JSON.parse(JSON.stringify(query));
|
2020-07-28 09:54:15 +03:00
|
|
|
},
|
|
|
|
errorFn: async (e) => {
|
2020-09-01 02:47:53 +03:00
|
|
|
console.log({
|
2020-07-28 09:54:15 +03:00
|
|
|
error: "GET_API_KEYS_BY_USER_ID",
|
|
|
|
source: e,
|
2020-09-01 02:47:53 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
return [];
|
2020-07-28 09:54:15 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|