Add UserEmail.fromUser()
This commit is contained in:
parent
924104f700
commit
26fdc94e9b
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wms-core",
|
||||
"version": "0.4.25",
|
||||
"version": "0.4.26",
|
||||
"description": "Node web framework",
|
||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||
|
@ -11,10 +11,14 @@ export default class UserEmail extends Model {
|
||||
}
|
||||
|
||||
public static async getMainFromUser(userID: number): Promise<UserEmail | null> {
|
||||
const emails = await this.models<UserEmail>(this.select().where('user_id', userID).where('main', 1));
|
||||
const emails = await this.models<UserEmail>(this.select().where('user_id', userID).where('main', 1).first());
|
||||
return emails.length > 0 ? emails[0] : null;
|
||||
}
|
||||
|
||||
public static async fromUser(userID: number): Promise<UserEmail[] | null> {
|
||||
return await this.models<UserEmail>(this.select().where('user_id', userID));
|
||||
}
|
||||
|
||||
public user_id?: number;
|
||||
public email?: string;
|
||||
private main?: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user