24 lines
547 B
TypeScript
24 lines
547 B
TypeScript
import db from "./db";
|
|
import type User from "../entities/user";
|
|
|
|
export function getID(userid: number): Promise<User | undefined>{
|
|
const user = db().select("*").from<User>("users").where("userid", userid).first().then((user) => {
|
|
return user;
|
|
});
|
|
return user;
|
|
};
|
|
|
|
export function createUser(username: string, email: string, website: string, password: string): Promise<number> {
|
|
return db()
|
|
.insert({
|
|
username: username,
|
|
email: email,
|
|
website: website,
|
|
password: password,
|
|
})
|
|
.into("users")
|
|
.then((n) => {
|
|
return n[0];
|
|
});
|
|
};
|