|
1 | 1 | import { ALL_PLATFORMS, ALL_SERVER_VERSIONS, ALL_TOPOLOGIES, ServerVersions } from './enums';
|
2 | 2 | import Help from './help';
|
3 |
| -import { BinaryType, bson as BSON } from '@mongosh/service-provider-core'; |
| 3 | +import { BinaryType, Document, bson as BSON } from '@mongosh/service-provider-core'; |
4 | 4 | import { CommonErrors, MongoshInternalError, MongoshInvalidInputError } from '@mongosh/errors';
|
5 | 5 | import { assertArgsDefinedType } from './helpers';
|
6 | 6 | import { randomBytes } from 'crypto';
|
@@ -51,34 +51,34 @@ export default function constructShellBson(bson: typeof BSON, printWarning: (msg
|
51 | 51 | (bson.BSONSymbol as any).prototype.deprecated = true;
|
52 | 52 |
|
53 | 53 | const bsonPkg = {
|
54 |
| - DBRef: Object.assign(function(namespace: string, oid: any, db?: string): typeof bson.DBRef.prototype { |
55 |
| - assertArgsDefinedType([namespace, oid, db], ['string', true, [undefined, 'string']], 'DBRef'); |
56 |
| - return new bson.DBRef(namespace, oid, db); |
57 |
| - }, { prototype: bson.DBRef.prototype }), |
| 54 | + DBRef: Object.assign(function DBRef(namespace: string, oid: any, db?: string, fields?: Document): typeof bson.DBRef.prototype { |
| 55 | + assertArgsDefinedType([namespace, oid, db], ['string', true, [undefined, 'string'], [undefined, 'object']], 'DBRef'); |
| 56 | + return new bson.DBRef(namespace, oid, db, fields); |
| 57 | + }, { ...bson.DBRef, prototype: bson.DBRef.prototype }), |
58 | 58 | // DBPointer not available in the bson 1.x library, but depreciated since 1.6
|
59 | 59 | Map: bson.Map,
|
60 |
| - bsonsize: function(object: any): number { |
| 60 | + bsonsize: function bsonsize(object: any): number { |
61 | 61 | assertArgsDefinedType([object], ['object'], 'bsonsize');
|
62 | 62 | return bson.calculateObjectSize(object);
|
63 | 63 | },
|
64 |
| - MaxKey: Object.assign(function(): typeof bson.MaxKey.prototype { |
| 64 | + MaxKey: Object.assign(function MaxKey(): typeof bson.MaxKey.prototype { |
65 | 65 | return new bson.MaxKey();
|
66 |
| - }, { prototype: bson.MaxKey.prototype }), |
67 |
| - MinKey: Object.assign(function(): typeof bson.MinKey.prototype { |
| 66 | + }, { ...bson.MaxKey, prototype: bson.MaxKey.prototype }), |
| 67 | + MinKey: Object.assign(function MinKey(): typeof bson.MinKey.prototype { |
68 | 68 | return new bson.MinKey();
|
69 |
| - }, { prototype: bson.MinKey.prototype }), |
70 |
| - ObjectId: Object.assign(function(id?: string | number | typeof bson.ObjectId.prototype | Buffer): typeof bson.ObjectId.prototype { |
| 69 | + }, { ...bson.MinKey, prototype: bson.MinKey.prototype }), |
| 70 | + ObjectId: Object.assign(function ObjectId(id?: string | number | typeof bson.ObjectId.prototype | Buffer): typeof bson.ObjectId.prototype { |
71 | 71 | assertArgsDefinedType([id], [[undefined, 'string', 'number', 'object']], 'ObjectId');
|
72 | 72 | return new bson.ObjectId(id);
|
73 |
| - }, { prototype: bson.ObjectId.prototype }), |
74 |
| - Timestamp: Object.assign(function(low?: number | typeof bson.Long.prototype, high?: number): typeof bson.Timestamp.prototype { |
| 73 | + }, { ...bson.ObjectId, prototype: bson.ObjectId.prototype }), |
| 74 | + Timestamp: Object.assign(function Timestamp(low?: number | typeof bson.Long.prototype, high?: number): typeof bson.Timestamp.prototype { |
75 | 75 | assertArgsDefinedType([low, high], [['number', 'object', undefined], [undefined, 'number']], 'Timestamp');
|
76 | 76 | return new bson.Timestamp(low as number, high as number);
|
77 |
| - }, { prototype: bson.Timestamp.prototype }), |
78 |
| - Code: Object.assign(function(c: string | Function = '', s?: any): typeof bson.Code.prototype { |
| 77 | + }, { ...bson.Timestamp, prototype: bson.Timestamp.prototype }), |
| 78 | + Code: Object.assign(function Code(c: string | Function = '', s?: any): typeof bson.Code.prototype { |
79 | 79 | assertArgsDefinedType([c, s], [[undefined, 'string', 'function'], [undefined, 'object']], 'Code');
|
80 | 80 | return new bson.Code(c, s);
|
81 |
| - }, { prototype: bson.Code.prototype }), |
| 81 | + }, { ...bson.Code, prototype: bson.Code.prototype }), |
82 | 82 | NumberDecimal: Object.assign(function(s = '0'): any {
|
83 | 83 | assertArgsDefinedType([s], [['string', 'number']], 'NumberDecimal');
|
84 | 84 | if (typeof s === 'string') {
|
|
0 commit comments