Browse Source

switch from updateOne to findOneAndUpdate to return new document

pull/1/head
Rob Colbert 3 years ago
parent
commit
0918b0822c
  1. 7
      app/services/oauth2.js

7
app/services/oauth2.js

@ -178,7 +178,7 @@ class OAuth2Service extends SiteService {
* calling host. * calling host.
*/ */
const client = await OAuth2Client.updateOne( const client = await OAuth2Client.findOneAndUpdate(
{ {
'site.domain': clientDefinition.domain, 'site.domain': clientDefinition.domain,
'site.domainKey': clientDefinition.domainKey, 'site.domainKey': clientDefinition.domainKey,
@ -199,7 +199,10 @@ class OAuth2Service extends SiteService {
redirectUri: clientDefinition.coreAuth.redirectUri, 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', { this.log.info('new OAuth2 client updated', {

Loading…
Cancel
Save