Skip to content

Commit e79ac9d

Browse files
authored
feat(NODE-4796)!: remove addUser and collection.stats APIs (#3781)
1 parent 52cd649 commit e79ac9d

File tree

16 files changed

+82
-932
lines changed

16 files changed

+82
-932
lines changed

src/admin.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type Document, resolveBSONOptions } from './bson';
22
import type { Db } from './db';
3-
import { AddUserOperation, type AddUserOptions } from './operations/add_user';
43
import type { CommandOperationOptions } from './operations/command';
54
import { executeOperation } from './operations/execute_operation';
65
import {
@@ -120,33 +119,6 @@ export class Admin {
120119
return this.command({ ping: 1 }, options);
121120
}
122121

123-
/**
124-
* Add a user to the database
125-
*
126-
* @param username - The username for the new user
127-
* @param passwordOrOptions - An optional password for the new user, or the options for the command
128-
* @param options - Optional settings for the command
129-
* @deprecated Use the createUser command in `db.command()` instead.
130-
* @see https://www.mongodb.com/docs/manual/reference/command/createUser/
131-
*/
132-
async addUser(
133-
username: string,
134-
passwordOrOptions?: string | AddUserOptions,
135-
options?: AddUserOptions
136-
): Promise<Document> {
137-
options =
138-
options != null && typeof options === 'object'
139-
? options
140-
: passwordOrOptions != null && typeof passwordOrOptions === 'object'
141-
? passwordOrOptions
142-
: undefined;
143-
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
144-
return executeOperation(
145-
this.s.db.client,
146-
new AddUserOperation(this.s.db, username, password, { dbName: 'admin', ...options })
147-
);
148-
}
149-
150122
/**
151123
* Remove a user from a database
152124
*

src/collection.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ import {
8080
} from './operations/search_indexes/create';
8181
import { DropSearchIndexOperation } from './operations/search_indexes/drop';
8282
import { UpdateSearchIndexOperation } from './operations/search_indexes/update';
83-
import { type CollStats, CollStatsOperation, type CollStatsOptions } from './operations/stats';
8483
import {
8584
ReplaceOneOperation,
8685
type ReplaceOptions,
@@ -799,21 +798,6 @@ export class Collection<TSchema extends Document = Document> {
799798
);
800799
}
801800

802-
/**
803-
* Get all the collection statistics.
804-
*
805-
* @deprecated the `collStats` operation will be removed in the next major release. Please
806-
* use an aggregation pipeline with the [`$collStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) stage instead
807-
*
808-
* @param options - Optional settings for the command
809-
*/
810-
async stats(options?: CollStatsOptions): Promise<CollStats> {
811-
return executeOperation(
812-
this.client,
813-
new CollStatsOperation(this as TODO_NODE_3286, options) as TODO_NODE_3286
814-
);
815-
}
816-
817801
/**
818802
* Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation.
819803
*

src/db.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { RunCommandCursor, type RunCursorCommandOptions } from './cursor/run_com
99
import { MongoAPIError, MongoInvalidArgumentError } from './error';
1010
import type { MongoClient, PkFactory } from './mongo_client';
1111
import type { TODO_NODE_3286 } from './mongo_types';
12-
import { AddUserOperation, type AddUserOptions } from './operations/add_user';
1312
import type { AggregateOptions } from './operations/aggregate';
1413
import { CollectionsOperation } from './operations/collections';
1514
import type { IndexInformationOptions } from './operations/common_functions';
@@ -425,33 +424,6 @@ export class Db {
425424
);
426425
}
427426

428-
/**
429-
* Add a user to the database
430-
*
431-
* @param username - The username for the new user
432-
* @param passwordOrOptions - An optional password for the new user, or the options for the command
433-
* @param options - Optional settings for the command
434-
* @deprecated Use the createUser command in `db.command()` instead.
435-
* @see https://www.mongodb.com/docs/manual/reference/command/createUser/
436-
*/
437-
async addUser(
438-
username: string,
439-
passwordOrOptions?: string | AddUserOptions,
440-
options?: AddUserOptions
441-
): Promise<Document> {
442-
options =
443-
options != null && typeof options === 'object'
444-
? options
445-
: passwordOrOptions != null && typeof passwordOrOptions === 'object'
446-
? passwordOrOptions
447-
: undefined;
448-
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
449-
return executeOperation(
450-
this.client,
451-
new AddUserOperation(this, username, password, resolveOptions(this, options))
452-
);
453-
}
454-
455427
/**
456428
* Remove a user from a database
457429
*

src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ export type {
378378
WithId,
379379
WithoutId
380380
} from './mongo_types';
381-
export type { AddUserOptions, RoleSpecification } from './operations/add_user';
382381
export type {
383382
AggregateOperation,
384383
AggregateOptions,
@@ -434,12 +433,7 @@ export type { RenameOptions } from './operations/rename';
434433
export type { RunCommandOptions } from './operations/run_command';
435434
export type { SearchIndexDescription } from './operations/search_indexes/create';
436435
export type { SetProfilingLevelOptions } from './operations/set_profiling_level';
437-
export type {
438-
CollStats,
439-
CollStatsOptions,
440-
DbStatsOptions,
441-
WiredTigerData
442-
} from './operations/stats';
436+
export type { DbStatsOptions } from './operations/stats';
443437
export type {
444438
ReplaceOptions,
445439
UpdateOptions,

src/operations/add_user.ts

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)