max_key.ts 698 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /** @public */
  2. export interface MaxKeyExtended {
  3. $maxKey: 1;
  4. }
  5. /**
  6. * A class representation of the BSON MaxKey type.
  7. * @public
  8. * @category BSONType
  9. */
  10. export class MaxKey {
  11. _bsontype!: 'MaxKey';
  12. constructor() {
  13. if (!(this instanceof MaxKey)) return new MaxKey();
  14. }
  15. /** @internal */
  16. toExtendedJSON(): MaxKeyExtended {
  17. return { $maxKey: 1 };
  18. }
  19. /** @internal */
  20. static fromExtendedJSON(): MaxKey {
  21. return new MaxKey();
  22. }
  23. /** @internal */
  24. [Symbol.for('nodejs.util.inspect.custom')](): string {
  25. return this.inspect();
  26. }
  27. inspect(): string {
  28. return 'new MaxKey()';
  29. }
  30. }
  31. Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' });