From 26fdc94e9b74a36f4c8ee5ab509c4d455d132af0 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 5 May 2020 17:17:29 +0200 Subject: [PATCH] Add UserEmail.fromUser() --- package.json | 2 +- src/auth/models/UserEmail.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ee7545c..4cb6749 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/auth/models/UserEmail.ts b/src/auth/models/UserEmail.ts index f037f2b..be2cc30 100644 --- a/src/auth/models/UserEmail.ts +++ b/src/auth/models/UserEmail.ts @@ -11,10 +11,14 @@ export default class UserEmail extends Model { } public static async getMainFromUser(userID: number): Promise { - const emails = await this.models(this.select().where('user_id', userID).where('main', 1)); + const emails = await this.models(this.select().where('user_id', userID).where('main', 1).first()); return emails.length > 0 ? emails[0] : null; } + public static async fromUser(userID: number): Promise { + return await this.models(this.select().where('user_id', userID)); + } + public user_id?: number; public email?: string; private main?: boolean;