ParallelSaveError:无法并行多次保存()同一个文档

coc*_*ave 7 mongoose node.js express passport.js

我将我的本地数据库移到了 mLab 的免费层,但我收到了以前没有遇到的错误。 ParallelSaveError: Can't save() the same doc multiple times in parallel

错误是从 line 捕获的user.save()。你能看一下,请说明如何修复它吗?我好失落...

// Confirm password.
// Execs after requiresAuth permission resolver.
const confirmPassword = ({ user, inputs: { password } }) => {
  // Validate args.
  validate([required, isLength], 'PASSWORD', password)

  // Required for graphql. Expects a promise.
  return new Promise((resolve, reject) =>
    user.comparePassword(password, (err, isMatch) => {
      if (err) return reject(err)
      if (!isMatch) return reject(error('CONFIRM_PASSWORD_FAILED'))
      return resolve(user)
    })
  )
}
Run Code Online (Sandbox Code Playgroud)
// Compare submitted plain text password with the salted and hashed version.
    UserSchema.methods.comparePassword = function(candidatePassword, callback) {
      return bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
        if (isMatch) {
          this.account.authStrikes = 0
          this.account.lastConfirm = Date.now()
        } else {
          this.account.authStrikes += 1
          if (this.account.authStrikes === 3) {
            this.account.status = 'locked'
            require('../resolvers/auth')
              .createUnlockAccountToken({ userId: this._id })
          }
        }
        return this.save()
          .then(() => callback(null, isMatch))
          .catch(err => callback(err))
      })
    }
Run Code Online (Sandbox Code Playgroud)