@mongosh/service-provider-core 1.7.1 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AUTHORS CHANGED
@@ -12,3 +12,4 @@ Alena Khineika <alena.khineika@gmail.com>
12
12
  Leonardo Rossi <leonardo.rossi@gmail.com>
13
13
  Le Roux Bodenstein <lerouxb@gmail.com>
14
14
  Bailey Pearson <bailey.pearson@mongodb.com>
15
+ Himanshu Singh <himanshu.singhs@outlook.in>
package/lib/admin.d.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  import ShellAuthOptions from './shell-auth-options';
2
- import type { MongoClientOptions, ReadConcern, ReadPreference, WriteConcern, Document, CreateCollectionOptions, ClientSession, DbOptions, ClientSessionOptions, ListDatabasesOptions, AutoEncryptionOptions } from './all-transport-types';
2
+ import type { MongoClientOptions, ReadConcern, ReadPreference, WriteConcern, Document, CreateCollectionOptions, ClientSession, DbOptions, ClientSessionOptions, ListDatabasesOptions, AutoEncryptionOptions, Collection } from './all-transport-types';
3
3
  import type { bson as BSON } from './index';
4
4
  import type { ReplPlatform } from './platform';
5
- import { FLE } from './all-fle-types';
5
+ import { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, ClientEncryption as MongoCryptClientEncryption, ClientEncryptionDataKeyProvider, FLE, GCPEncryptionKeyOptions } from './all-fle-types';
6
+ export interface CreateEncryptedCollectionOptions {
7
+ provider: ClientEncryptionDataKeyProvider;
8
+ createCollectionOptions: Omit<CreateCollectionOptions, 'encryptedFields'> & {
9
+ encryptedFields: Document;
10
+ };
11
+ masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions;
12
+ }
6
13
  export default interface Admin {
7
14
  platform: ReplPlatform;
8
15
  initialDb: string;
@@ -25,4 +32,8 @@ export default interface Admin {
25
32
  getRawClient(): any;
26
33
  fle?: FLE | undefined;
27
34
  getFleOptions?: () => AutoEncryptionOptions | undefined;
35
+ createEncryptedCollection?(dbName: string, collName: string, options: CreateEncryptedCollectionOptions, libmongocrypt: MongoCryptClientEncryption): Promise<{
36
+ collection: Collection;
37
+ encryptedFields: Document;
38
+ }>;
28
39
  }
package/lib/index.d.ts CHANGED
@@ -3,12 +3,13 @@ import ServiceProvider, { ServiceProviderCore } from './service-provider';
3
3
  import getConnectInfo, { ConnectInfo } from './connect-info';
4
4
  import type { ReplPlatform } from './platform';
5
5
  declare const DEFAULT_DB = "test";
6
- import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, EJSON, BSONRegExp } from 'bson';
6
+ import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, BSONRegExp } from 'bson';
7
7
  import { bsonStringifiers } from './printable-bson';
8
8
  import ShellAuthOptions from './shell-auth-options';
9
9
  export * from './all-transport-types';
10
10
  export * from './all-fle-types';
11
11
  export { MapReduceOptions, FinalizeFunction } from './map-reduce-options';
12
+ export { CreateEncryptedCollectionOptions } from './admin';
12
13
  declare const bson: {
13
14
  ObjectId: typeof ObjectId;
14
15
  DBRef: typeof DBRef;
@@ -21,10 +22,14 @@ declare const bson: {
21
22
  Int32: typeof Int32;
22
23
  Long: typeof Long;
23
24
  Binary: typeof Binary;
24
- Map: MapConstructor;
25
25
  calculateObjectSize: typeof calculateObjectSize;
26
26
  Double: typeof Double;
27
- EJSON: typeof EJSON;
27
+ EJSON: {
28
+ parse: (text: string, options?: import("bson").EJSONOptions | undefined) => any;
29
+ stringify: (value: any, replacer?: (string | number)[] | import("bson").EJSONOptions | ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined, options?: import("bson").EJSONOptions | undefined) => string;
30
+ serialize: (value: any, options?: import("bson").EJSONOptions | undefined) => import("bson").Document;
31
+ deserialize: (ejson: import("bson").Document, options?: import("bson").EJSONOptions | undefined) => any;
32
+ };
28
33
  BSONRegExp: typeof BSONRegExp;
29
34
  };
30
35
  export { ServiceProvider, ShellAuthOptions, getConnectInfo, ReplPlatform, DEFAULT_DB, ServiceProviderCore, bson, bsonStringifiers, ConnectInfo };
package/lib/index.js CHANGED
@@ -42,7 +42,6 @@ const bson = {
42
42
  Int32: bson_1.Int32,
43
43
  Long: bson_1.Long,
44
44
  Binary: bson_1.Binary,
45
- Map: bson_1.Map,
46
45
  calculateObjectSize: bson_1.calculateObjectSize,
47
46
  Double: bson_1.Double,
48
47
  EJSON: bson_1.EJSON,
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAA0E;AAsDxE,oGAtDwB,sCAAmB,OAsDxB;AArDrB,kEAA6D;AAkD3D,yBAlDK,sBAAc,CAkDL;AAhDhB,MAAM,UAAU,GAAG,MAAM,CAAC;AAkDxB,gCAAU;AAjDZ,+BAiBc;AACd,qDAAoD;AAkClD,iGAlCO,iCAAgB,OAkCP;AAhClB,wDAAsC;AACtC,kDAAgC;AAIhC,MAAM,IAAI,GAAG;IACX,QAAQ,EAAR,eAAQ;IACR,KAAK,EAAL,YAAK;IACL,MAAM,EAAN,aAAM;IACN,MAAM,EAAN,aAAM;IACN,SAAS,EAAT,gBAAS;IACT,UAAU,EAAV,iBAAU;IACV,IAAI,EAAJ,WAAI;IACJ,UAAU,EAAV,iBAAU;IACV,KAAK,EAAL,YAAK;IACL,IAAI,EAAJ,WAAI;IACJ,MAAM,EAAN,aAAM;IACN,GAAG,EAAH,UAAG;IACH,mBAAmB,EAAnB,0BAAmB;IACnB,MAAM,EAAN,aAAM;IACN,KAAK,EAAL,YAAK;IACL,UAAU,EAAV,iBAAU;CACX,CAAC;AASA,oBAAI"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAA0E;AAsDxE,oGAtDwB,sCAAmB,OAsDxB;AArDrB,kEAA6D;AAkD3D,yBAlDK,sBAAc,CAkDL;AAhDhB,MAAM,UAAU,GAAG,MAAM,CAAC;AAkDxB,gCAAU;AAjDZ,+BAgBc;AACd,qDAAoD;AAmClD,iGAnCO,iCAAgB,OAmCP;AAjClB,wDAAsC;AACtC,kDAAgC;AAMhC,MAAM,IAAI,GAAG;IACX,QAAQ,EAAR,eAAQ;IACR,KAAK,EAAL,YAAK;IACL,MAAM,EAAN,aAAM;IACN,MAAM,EAAN,aAAM;IACN,SAAS,EAAT,gBAAS;IACT,UAAU,EAAV,iBAAU;IACV,IAAI,EAAJ,WAAI;IACJ,UAAU,EAAV,iBAAU;IACV,KAAK,EAAL,YAAK;IACL,IAAI,EAAJ,WAAI;IACJ,MAAM,EAAN,aAAM;IACN,mBAAmB,EAAnB,0BAAmB;IACnB,MAAM,EAAN,aAAM;IACN,KAAK,EAAL,YAAK;IACL,UAAU,EAAV,iBAAU;CACX,CAAC;AASA,oBAAI"}
@@ -9,7 +9,7 @@ exports.bsonStringifiers = {
9
9
  return `ObjectId("${this.toHexString()}")`;
10
10
  },
11
11
  DBRef: function (depth, options) {
12
- return `DBRef("${this.namespace}", ` +
12
+ return `DBRef("${this.collection}", ` +
13
13
  (0, util_1.inspect)(this.oid, options) +
14
14
  (this.db ? `, "${this.db}"` : '') +
15
15
  ')';
@@ -43,19 +43,18 @@ exports.bsonStringifiers = {
43
43
  return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
44
44
  },
45
45
  Binary: function () {
46
- const asBuffer = this.value(true);
46
+ const hexString = this.toString('hex');
47
47
  switch (this.sub_type) {
48
48
  case index_1.bson.Binary.SUBTYPE_MD5:
49
- return `MD5("${asBuffer.toString('hex')}")`;
49
+ return `MD5("${hexString}")`;
50
50
  case index_1.bson.Binary.SUBTYPE_UUID:
51
- if (asBuffer.length === 16) {
52
- const hex = asBuffer.toString('hex');
53
- const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
51
+ if (hexString.length === 32) {
52
+ const asUUID = hexString.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
54
53
  .slice(1, 6).join('-');
55
54
  return `UUID("${asUUID}")`;
56
55
  }
57
56
  default:
58
- return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
57
+ return `Binary(Buffer.from("${hexString}", "hex"), ${this.sub_type})`;
59
58
  }
60
59
  },
61
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"printable-bson.js","sourceRoot":"","sources":["../src/printable-bson.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AACvC,+BAA+B;AAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAElD,QAAA,gBAAgB,GAAoE;IAC/F,QAAQ,EAAE;QACR,OAAO,aAAa,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAC7C,CAAC;IAED,KAAK,EAAE,UAAS,KAAU,EAAE,OAAY;QACtC,OAAO,UAAU,IAAI,CAAC,SAAS,KAAK;YAClC,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;YAC1B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,GAAG,CAAC;IACR,CAAC;IAED,MAAM,EAAE;QACN,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,EAAE;QACN,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,SAAS,EAAE;QACT,OAAO,kBAAkB,IAAI,CAAC,WAAW,EAAE,QAAQ,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC;IAC5E,CAAC;IAED,UAAU,EAAE;QACV,OAAO,eAAe,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IAC3C,CAAC;IAED,IAAI,EAAE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,CAAC,KAAK,CAAC,CAAC;QACvC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACrB,KAAK,YAAI,CAAC,MAAM,CAAC,WAAW;gBAC1B,OAAO,QAAQ,SAAS,IAAI,CAAC;YAC/B,KAAK,YAAI,CAAC,MAAM,CAAC,YAAY;gBAC3B,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,EAAE;oBAG3B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAE;yBACjE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACzB,OAAO,SAAS,MAAM,IAAI,CAAC;iBAC5B;YAGH;gBACE,OAAO,uBAAuB,SAAS,cAAc,IAAI,CAAC,QAAQ,GAAG,CAAC;SACzE;IACH,CAAC;CACF,CAAC;AACF,wBAAgB,CAAC,QAAQ,GAAG,wBAAgB,CAAC,QAAQ,CAAC;AAOtD,mBAAwB,IAAkB;IACxC,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,GAAG,YAAI,CAAC;KACb;IAED,KAAK,MAAM,CAAE,GAAG,EAAE,WAAW,CAAE,IAAI,MAAM,CAAC,OAAO,CAAC,wBAAgB,CAAC,EAAE;QACnE,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE;YAClB,SAAS;SACV;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAwB,CAAC,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE;YAC5C,IAAI;gBACD,GAAW,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;aAC3C;YAAC,WAAM;aAKP;SACF;KACF;AACH,CAAC;AArBD,4BAqBC"}
package/lib/writable.d.ts CHANGED
@@ -14,7 +14,6 @@ export default interface Writable {
14
14
  replaceOne(database: string, collection: string, filter: Document, replacement: Document, options?: ReplaceOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
15
15
  updateMany(database: string, collection: string, filter: Document, update: Document, options?: UpdateOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
16
16
  updateOne(database: string, collection: string, filter: Document, update: Document, options?: UpdateOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
17
- remove(database: string, collection: string, query: Document, options?: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
18
17
  createIndexes(database: string, collection: string, indexSpecs: Document[], options?: CreateIndexesOptions, dbOptions?: DbOptions): Promise<string[]>;
19
18
  dropCollection(database: string, collection: string, options: DropCollectionOptions, dbOptions?: DbOptions): Promise<boolean>;
20
19
  renameCollection(database: string, oldName: string, newName: string, options?: RenameOptions, dbOptions?: DbOptions): Promise<Collection>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/service-provider-core",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "description": "MongoDB Shell Core Service Provider Package",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -38,14 +38,14 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@aws-sdk/credential-providers": "^3.262.0",
41
- "@mongosh/errors": "1.7.1",
42
- "bson": "^4.7.2",
43
- "mongodb": "^4.13.0",
41
+ "@mongosh/errors": "1.8.1",
42
+ "bson": "^5.2.0",
43
+ "mongodb": "^5.3.0",
44
44
  "mongodb-build-info": "^1.5.0",
45
- "mongodb-client-encryption": "^2.4.0"
45
+ "mongodb-client-encryption": "^2.7.1"
46
46
  },
47
47
  "optionalDependencies": {
48
- "mongodb-client-encryption": "^2.4.0"
48
+ "mongodb-client-encryption": "^2.7.1"
49
49
  },
50
50
  "dependency-check": {
51
51
  "entries": [
@@ -58,5 +58,5 @@
58
58
  "encoding"
59
59
  ]
60
60
  },
61
- "gitHead": "1bf0d7775443ac1849cc2597465d54eca867acea"
61
+ "gitHead": "b0244ae6670f5a0f375abbb38bcf3465917de6e4"
62
62
  }
package/src/admin.ts CHANGED
@@ -10,12 +10,25 @@ import type {
10
10
  DbOptions,
11
11
  ClientSessionOptions,
12
12
  ListDatabasesOptions,
13
- AutoEncryptionOptions
13
+ AutoEncryptionOptions,
14
+ Collection
14
15
  } from './all-transport-types';
15
16
  import type { bson as BSON } from './index';
16
17
  import type { ReplPlatform } from './platform';
17
- import { FLE } from './all-fle-types';
18
-
18
+ import {
19
+ AWSEncryptionKeyOptions,
20
+ AzureEncryptionKeyOptions,
21
+ ClientEncryption as MongoCryptClientEncryption,
22
+ ClientEncryptionDataKeyProvider,
23
+ FLE,
24
+ GCPEncryptionKeyOptions
25
+ } from './all-fle-types';
26
+
27
+ export interface CreateEncryptedCollectionOptions {
28
+ provider: ClientEncryptionDataKeyProvider,
29
+ createCollectionOptions: Omit<CreateCollectionOptions, 'encryptedFields'> & { encryptedFields: Document },
30
+ masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions | GCPEncryptionKeyOptions;
31
+ }
19
32
 
20
33
  export default interface Admin {
21
34
  /**
@@ -116,4 +129,14 @@ export default interface Admin {
116
129
  * The FLE options passed to the client, if any.
117
130
  */
118
131
  getFleOptions?: () => AutoEncryptionOptions | undefined;
132
+
133
+ /**
134
+ * The helper method to correctly access FLE implementation's createEncryptedCollection
135
+ */
136
+ createEncryptedCollection?(
137
+ dbName: string,
138
+ collName: string,
139
+ options: CreateEncryptedCollectionOptions,
140
+ libmongocrypt: MongoCryptClientEncryption
141
+ ): Promise<{ collection: Collection, encryptedFields: Document }>
119
142
  }
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  Int32,
16
16
  Long,
17
17
  Binary,
18
- Map,
19
18
  calculateObjectSize,
20
19
  Double,
21
20
  EJSON,
@@ -28,6 +27,8 @@ export * from './all-fle-types';
28
27
 
29
28
  export { MapReduceOptions, FinalizeFunction } from './map-reduce-options';
30
29
 
30
+ export { CreateEncryptedCollectionOptions } from './admin';
31
+
31
32
  const bson = {
32
33
  ObjectId,
33
34
  DBRef,
@@ -40,7 +41,6 @@ const bson = {
40
41
  Int32,
41
42
  Long,
42
43
  Binary,
43
- Map,
44
44
  calculateObjectSize,
45
45
  Double,
46
46
  EJSON,
@@ -3,72 +3,71 @@ import { inspect } from 'util';
3
3
  const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
4
4
 
5
5
  export const bsonStringifiers: Record<string, (this: any, depth: any, options: any) => string> = {
6
- ObjectId: function(): string {
6
+ ObjectId: function(this: typeof BSON.ObjectId.prototype): string {
7
7
  return `ObjectId("${this.toHexString()}")`;
8
8
  },
9
9
 
10
- DBRef: function(depth: any, options: any): string {
11
- return `DBRef("${this.namespace}", ` +
10
+ DBRef: function(this: typeof BSON.DBRef.prototype, depth: any, options: any): string {
11
+ return `DBRef("${this.collection}", ` +
12
12
  inspect(this.oid, options) +
13
13
  (this.db ? `, "${this.db}"` : '') +
14
14
  ')';
15
15
  },
16
16
 
17
- MaxKey: function(): string {
17
+ MaxKey: function(this: typeof BSON.MaxKey.prototype): string {
18
18
  return 'MaxKey()';
19
19
  },
20
20
 
21
- MinKey: function(): string {
21
+ MinKey: function(this: typeof BSON.MinKey.prototype): string {
22
22
  return 'MinKey()';
23
23
  },
24
24
 
25
- Timestamp: function(): string {
25
+ Timestamp: function(this: typeof BSON.Timestamp.prototype): string {
26
26
  return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
27
27
  },
28
28
 
29
- BSONSymbol: function(): string {
29
+ BSONSymbol: function(this: typeof BSON.BSONSymbol.prototype): string {
30
30
  return `BSONSymbol("${this.valueOf()}")`;
31
31
  },
32
32
 
33
- Code: function(): string {
33
+ Code: function(this: typeof BSON.Code.prototype): string {
34
34
  const j = this.toJSON();
35
35
  return `Code("${j.code}"${j.scope ? `, ${JSON.stringify(j.scope)}` : ''})`;
36
36
  },
37
37
 
38
- Decimal128: function(): string {
38
+ Decimal128: function(this: typeof BSON.Decimal128.prototype): string {
39
39
  return `Decimal128("${this.toString()}")`;
40
40
  },
41
41
 
42
- Int32: function(): string {
42
+ Int32: function(this: typeof BSON.Int32.prototype): string {
43
43
  return `Int32(${this.valueOf()})`;
44
44
  },
45
45
 
46
- Long: function(): string {
46
+ Long: function(this: typeof BSON.Long.prototype): string {
47
47
  return `Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
48
48
  },
49
49
 
50
- BSONRegExp: function(): string {
50
+ BSONRegExp: function(this: typeof BSON.BSONRegExp.prototype): string {
51
51
  return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
52
52
  },
53
53
 
54
- Binary: function(): string {
55
- const asBuffer = this.value(true);
54
+ Binary: function(this: typeof BSON.Binary.prototype): string {
55
+ const hexString = this.toString('hex');
56
56
  switch (this.sub_type) {
57
57
  case BSON.Binary.SUBTYPE_MD5:
58
- return `MD5("${asBuffer.toString('hex')}")`;
58
+ return `MD5("${hexString}")`;
59
59
  case BSON.Binary.SUBTYPE_UUID:
60
- if (asBuffer.length === 16) {
60
+ if (hexString.length === 32) {
61
61
  // Format '0123456789abcdef0123456789abcdef' into
62
62
  // '01234567-89ab-cdef-0123-456789abcdef'.
63
- const hex = asBuffer.toString('hex');
64
- const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
63
+ const asUUID = hexString.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)!
65
64
  .slice(1, 6).join('-');
66
65
  return `UUID("${asUUID}")`;
67
66
  }
68
67
  // In case somebody did something weird and used an UUID with a
69
68
  // non-standard length, fall through.
70
69
  default:
71
- return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
70
+ return `Binary(Buffer.from("${hexString}", "hex"), ${this.sub_type})`;
72
71
  }
73
72
  },
74
73
  };
package/src/writable.ts CHANGED
@@ -281,24 +281,6 @@ export default interface Writable {
281
281
  options?: UpdateOptions,
282
282
  dbOptions?: DbOptions): Promise<UpdateResult>;
283
283
 
284
- /**
285
- * Deprecated remove command.
286
- *
287
- * @param {String} database - The db name.
288
- * @param {String} collection - The collection name.
289
- * @param {Object} query - The query.
290
- * @param {Object} options - The options.
291
- * @param {DbOptions} dbOptions - The database options
292
- *
293
- * @return {Promise}
294
- */
295
- remove(
296
- database: string,
297
- collection: string,
298
- query: Document,
299
- options?: DeleteOptions,
300
- dbOptions?: DbOptions): Promise<DeleteResult>;
301
-
302
284
  /**
303
285
  * Adds new indexes to a collection.
304
286
  *