From 49fc92df5cbf10456b596e53b016f4c0db5697e5 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 25 Apr 2020 16:09:13 +0200 Subject: [PATCH] Add UserEmail.getMainFromUser --- src/auth/models/UserEmail.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/auth/models/UserEmail.ts b/src/auth/models/UserEmail.ts index 8ef284c..f037f2b 100644 --- a/src/auth/models/UserEmail.ts +++ b/src/auth/models/UserEmail.ts @@ -10,6 +10,11 @@ export default class UserEmail extends Model { return emails.length > 0 ? emails[0] : null; } + public static async getMainFromUser(userID: number): Promise { + const emails = await this.models(this.select().where('user_id', userID).where('main', 1)); + return emails.length > 0 ? emails[0] : null; + } + public user_id?: number; public email?: string; private main?: boolean;