MCPcopy
hub / github.com/mongodb/node-mongodb-native / constructor

Method constructor

src/cmap/commands.ts:670–706  ·  view source on GitHub ↗
(
    message: Uint8Array,
    msgHeader: MessageHeader,
    msgBody: Uint8Array,
    opts?: BSONSerializeOptions
  )

Source from the content-addressed store, hash-verified

668 sections: Uint8Array[] = [];
669
670 constructor(
671 message: Uint8Array,
672 msgHeader: MessageHeader,
673 msgBody: Uint8Array,
674 opts?: BSONSerializeOptions
675 ) {
676 this.parsed = false;
677 this.raw = message;
678 this.data = msgBody;
679 this.opts = opts ?? {
680 useBigInt64: false,
681 promoteLongs: true,
682 promoteValues: true,
683 promoteBuffers: false,
684 bsonRegExp: false
685 };
686
687 // Read the message header
688 this.length = msgHeader.length;
689 this.requestId = msgHeader.requestId;
690 this.responseTo = msgHeader.responseTo;
691 this.opCode = msgHeader.opCode;
692 this.fromCompressed = msgHeader.fromCompressed;
693
694 // Read response flags
695 this.responseFlags = readInt32LE(msgBody, 0);
696 this.checksumPresent = (this.responseFlags & OPTS_CHECKSUM_PRESENT) !== 0;
697 this.moreToCome = (this.responseFlags & OPTS_MORE_TO_COME) !== 0;
698 this.exhaustAllowed = (this.responseFlags & OPTS_EXHAUST_ALLOWED) !== 0;
699 this.useBigInt64 = typeof this.opts.useBigInt64 === 'boolean' ? this.opts.useBigInt64 : false;
700 this.promoteLongs = typeof this.opts.promoteLongs === 'boolean' ? this.opts.promoteLongs : true;
701 this.promoteValues =
702 typeof this.opts.promoteValues === 'boolean' ? this.opts.promoteValues : true;
703 this.promoteBuffers =
704 typeof this.opts.promoteBuffers === 'boolean' ? this.opts.promoteBuffers : false;
705 this.bsonRegExp = typeof this.opts.bsonRegExp === 'boolean' ? this.opts.bsonRegExp : false;
706 }
707
708 isParsed(): boolean {
709 return this.parsed;

Callers

nothing calls this directly

Calls 1

readInt32LEFunction · 0.90

Tested by

no test coverage detected