title: MongoDB updateOne with upsert not inserting document
body: <p>I have a nodejs Discord bot that is trying to update/insert a document in a mongodb (v4.2.2). I've done this many times, but for some reason, this particular function is just not working and I cannot find my error. </p>
  
  <pre><code>quit: async function ( memberId ) {
      console.log (memberId)  //checks out
      let member = await client.db('players').collection('suspensions').findOne({ _id: memberId }) 
      console.log(member) //null
      if ( !member ) {
          console.log('member not found') //i see this, so I know it's trying
          try {
              client.db('players').collection('suspensions').updateOne(
                  { _id: memberId },
                  {
                      $set: {
                          "quit.tier": 0,
                          "minor.tier": 0,
                          "moderate.tier": 0,
                          "major.tier": 0,
                          suspended: 0,
                          quitter: 0
                      }
                  },
                  {
                      $currentDate: {
                          ends: true,
                      }
                  },
                  { upsert: true }).then( (err, results) =&gt; {
                      console.log('in callback') //i see this, so I know it's getting here
                      if (err) console.log(err) //see error below
                      console.log(results)  //undefined
                      return
                  }
              )
          }
          catch ( e ) {
              console.log (e) //never gets here
              return;
          }
      }
  }
  
  </code></pre>
  
  <p>error output:</p>
  
  <pre><code>CommandResult {
    result: { n: 0, nModified: 0, ok: 1 },
    connection: Connection {
      _events: [Object: null prototype] {
        commandStarted: [Function (anonymous)],
        commandFailed: [Function (anonymous)],
        commandSucceeded: [Function (anonymous)],
        clusterTimeReceived: [Function (anonymous)]
      },
      _eventsCount: 4,
      _maxListeners: undefined,
      id: 1,
      address: '127.0.0.1:27017',
      bson: BSON {},
      socketTimeout: 360000,
      monitorCommands: false,
      closed: false,
      destroyed: false,
      lastIsMasterMS: 1,
      [Symbol(kCapture)]: false,
      [Symbol(description)]: StreamDescription {
        address: '127.0.0.1:27017',
        type: 'Standalone',
        minWireVersion: 0,
        maxWireVersion: 8,
        maxBsonObjectSize: 16777216,
        maxMessageSizeBytes: 48000000,
        maxWriteBatchSize: 100000,
        compressors: []
      },
      [Symbol(generation)]: 0,
      [Symbol(lastUseTime)]: 1589941704648,
      [Symbol(queue)]: Map(0) {},
      [Symbol(messageStream)]: MessageStream {
        _readableState: [ReadableState],
        readable: true,
        _events: [Object: null prototype],
        _eventsCount: 7,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: true,
        bson: BSON {},
        maxBsonMessageSize: 67108864,
        [Symbol(kCapture)]: false,
        [Symbol(buffer)]: [BufferList]
      },
      [Symbol(stream)]: Socket {
        connecting: false,
        _hadError: false,
        _parent: null,
        _host: 'localhost',
        _readableState: [ReadableState],
        readable: true,
        _events: [Object: null prototype],
        _eventsCount: 7,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: true,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: null,
        _server: null,
        timeout: 360000,
        _peername: [Object],
        [Symbol(asyncId)]: 229,
        [Symbol(kHandle)]: [TCP],
        [Symbol(kSetNoDelay)]: true,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: Timeout {
          _idleTimeout: 360000,
          _idlePrev: [TimersList],
          _idleNext: [Timeout],
          _idleStart: 5042,
          _onTimeout: [Function: bound ],
          _timerArgs: undefined,
          _repeat: null,
          _destroyed: false,
          [Symbol(refed)]: false,
          [Symbol(asyncId)]: 243,
          [Symbol(triggerId)]: 229
        },
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0
      },
      [Symbol(ismaster)]: {
        ismaster: true,
        maxBsonObjectSize: 16777216,
        maxMessageSizeBytes: 48000000,
        maxWriteBatchSize: 100000,
        localTime: 2020-05-20T02:28:24.642Z,
        logicalSessionTimeoutMinutes: 30,
        connectionId: 2794,
        minWireVersion: 0,
        maxWireVersion: 8,
        readOnly: false,
        ok: 1
      }
    },
    message: BinMsg {
      parsed: true,
      raw: &lt;Buffer 3c 00 00 00 0b 37 04 00 08 00 00 00 dd 07 00 00 00 00 00 00 00 27 00 00 00 10 6e 00 00 00 00 00 10 6e 4d 6f 64 69 66 69 65 64 00 00 00 00 00 01 6f 6b ... 10 more bytes&gt;,
      data: &lt;Buffer 00 00 00 00 00 27 00 00 00 10 6e 00 00 00 00 00 10 6e 4d 6f 64 69 66 69 65 64 00 00 00 00 00 01 6f 6b 00 00 00 00 00 00 00 f0 3f 00&gt;,
      bson: BSON {},
      opts: { promoteLongs: true, promoteValues: true, promoteBuffers: false },
      length: 60,
      requestId: 276235,
      responseTo: 8,
      opCode: 2013,
      fromCompressed: undefined,
      responseFlags: 0,
      checksumPresent: false,
      moreToCome: false,
      exhaustAllowed: false,
      promoteLongs: true,
      promoteValues: true,
      promoteBuffers: false,
      documents: [ [Object] ],
      index: 44
    },
    modifiedCount: 0,
    upsertedId: null,
    upsertedCount: 0,
    matchedCount: 0
  }
  </code></pre>
  
  <p>Note that I am able to run the similar updateOne command from the mongo UI and it inserts just fine:</p>
  
  <pre><code>&gt; use players
  switched to db players
  &gt; db.suspensions.updateOne({ _id: '313389427671957504' }, { $set: { "quit.tier": 0, "minor.tier": 0,"moderate.tier": 0,"major.tier": 0,suspended: 0,quitter: 0 } }, { upsert: true })
  {
          "acknowledged" : true,
          "matchedCount" : 0,
          "modifiedCount" : 0,
          "upsertedId" : "313389427671957504"
  }
  &gt; db.suspensions.find()
  { "_id" : "313389427671957504", "major" : { "tier" : 0 }, "minor" : { "tier" : 0 }, "moderate" : { "tier" : 0 }, "quit" : { "tier" : 0 }, "quitter" : 0, "suspended" : 0 }```
  </code></pre>