BigInt Value is not serialized correctly

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • bson-1.1.6, bson-4.2.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      https://github.com/mongodb/js-bson/issues/363

      when use BigInt value, I can simply add toBSON method this BigInt.prototype

      BigInt.prototype.toBSON = function() {
      	return this.toString()
      }
      

      But when pass the 0n value, bson serializer is not working on this line:

      //Line 689 in serializer.js
           // you should test value as a nil value but not a `0n` value.
            if (value && value.toBSON) {
              if (typeof value.toBSON !== 'function') throw new TypeError('toBSON is not a function');
              value = value.toBSON();
            }
      

      Or you could just add BigInt value support.

              Assignee:
              Unassigned
              Reporter:
              Backlog - Core Eng Program Management Team
              None
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: