From 0918b0822c173adf1dd1232e08e3fe4181942775 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 3 Jul 2022 12:22:27 -0400 Subject: [PATCH] switch from updateOne to findOneAndUpdate to return new document --- app/services/oauth2.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/oauth2.js b/app/services/oauth2.js index c581ec1..36e77e2 100644 --- a/app/services/oauth2.js +++ b/app/services/oauth2.js @@ -178,7 +178,7 @@ class OAuth2Service extends SiteService { * calling host. */ - const client = await OAuth2Client.updateOne( + const client = await OAuth2Client.findOneAndUpdate( { 'site.domain': clientDefinition.domain, 'site.domainKey': clientDefinition.domainKey, @@ -199,7 +199,10 @@ class OAuth2Service extends SiteService { redirectUri: clientDefinition.coreAuth.redirectUri, }, }, - { upsert: true, returnDocument: true }, + { + upsert: true, // create if it doesn't exist + "new": true, // return the modified version + }, ); this.log.info('new OAuth2 client updated', {