Skip to content

Commit cdfff2d

Browse files
committed
feat(NODE-4796)!: remove addUser and collection.stats APIs
1 parent 6a5c492 commit cdfff2d

File tree

15 files changed

+25
-799
lines changed

15 files changed

+25
-799
lines changed

Diff for: src/admin.ts

-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Document } 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 {
@@ -116,33 +115,6 @@ export class Admin {
116115
return this.command({ ping: 1 }, options);
117116
}
118117

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

Diff for: src/collection.ts

-16
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
*

Diff for: src/db.ts

-28
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';
@@ -418,33 +417,6 @@ export class Db {
418417
);
419418
}
420419

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

Diff for: src/index.ts

+1-7
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,

Diff for: src/operations/add_user.ts

-117
This file was deleted.

0 commit comments

Comments
 (0)