Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3029

BigInt Value is not serialized correctly

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

      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 Unassigned
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: