mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-18 22:51:32 +03:00
30 lines
605 B
JavaScript
30 lines
605 B
JavaScript
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
export default async ({ username }) => {
|
|
return await runQuery({
|
|
label: "GET_USER_BY_USERNAME",
|
|
queryFn: async (DB) => {
|
|
const query = await DB.select("*")
|
|
.from("users")
|
|
.where({ username })
|
|
.first();
|
|
|
|
if (!query || query.error) {
|
|
return null;
|
|
}
|
|
|
|
if (query.id) {
|
|
return JSON.parse(JSON.stringify(query));
|
|
}
|
|
|
|
return null;
|
|
},
|
|
errorFn: async (e) => {
|
|
return {
|
|
error: true,
|
|
decorator: "GET_USER_BY_USERNAME",
|
|
};
|
|
},
|
|
});
|
|
};
|