From 6f96900ab9ef24089f69e8e50a91a65e4efda7d0 Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 13 Jan 2022 12:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dopenapi=20token=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/open.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/back/services/open.ts b/back/services/open.ts index 924b277a..2abecc7b 100644 --- a/back/services/open.ts +++ b/back/services/open.ts @@ -12,15 +12,9 @@ export default class OpenService { constructor(@Inject('logger') private logger: winston.Logger) {} public async findTokenByValue(token: string): Promise { - const doc = await this.getDb( - sequelize.fn( - 'JSON_CONTAINS', - sequelize.col('tokens'), - JSON.stringify({ value: token }), - ), - ); - return doc; - AppModel.upsert; + const docs = await this.find({}); + const doc = docs.filter((x) => x.tokens?.find((y) => y.value === token)); + return doc[0]; } public async create(payload: App): Promise {