Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-4796)!: remove addUser and collection.stats APIs #3781

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/admin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Document } from './bson';
import type { Db } from './db';
import { AddUserOperation, type AddUserOptions } from './operations/add_user';
import type { CommandOperationOptions } from './operations/command';
import { executeOperation } from './operations/execute_operation';
import {
Expand Down Expand Up @@ -116,33 +115,6 @@ export class Admin {
return this.command({ ping: 1 }, options);
}

/**
* Add a user to the database
*
* @param username - The username for the new user
* @param passwordOrOptions - An optional password for the new user, or the options for the command
* @param options - Optional settings for the command
* @deprecated Use the createUser command in `db.command()` instead.
* @see https://www.mongodb.com/docs/manual/reference/command/createUser/
*/
async addUser(
username: string,
passwordOrOptions?: string | AddUserOptions,
options?: AddUserOptions
): Promise<Document> {
options =
options != null && typeof options === 'object'
? options
: passwordOrOptions != null && typeof passwordOrOptions === 'object'
? passwordOrOptions
: undefined;
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
return executeOperation(
this.s.db.client,
new AddUserOperation(this.s.db, username, password, { dbName: 'admin', ...options })
);
}

/**
* Remove a user from a database
*
Expand Down
16 changes: 0 additions & 16 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import {
} from './operations/search_indexes/create';
import { DropSearchIndexOperation } from './operations/search_indexes/drop';
import { UpdateSearchIndexOperation } from './operations/search_indexes/update';
import { type CollStats, CollStatsOperation, type CollStatsOptions } from './operations/stats';
import {
ReplaceOneOperation,
type ReplaceOptions,
Expand Down Expand Up @@ -799,21 +798,6 @@ export class Collection<TSchema extends Document = Document> {
);
}

/**
* Get all the collection statistics.
*
* @deprecated the `collStats` operation will be removed in the next major release. Please
* use an aggregation pipeline with the [`$collStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) stage instead
*
* @param options - Optional settings for the command
*/
async stats(options?: CollStatsOptions): Promise<CollStats> {
return executeOperation(
this.client,
new CollStatsOperation(this as TODO_NODE_3286, options) as TODO_NODE_3286
);
}

/**
* Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation.
*
Expand Down
28 changes: 0 additions & 28 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { RunCommandCursor, type RunCursorCommandOptions } from './cursor/run_com
import { MongoAPIError, MongoInvalidArgumentError } from './error';
import type { MongoClient, PkFactory } from './mongo_client';
import type { TODO_NODE_3286 } from './mongo_types';
import { AddUserOperation, type AddUserOptions } from './operations/add_user';
import type { AggregateOptions } from './operations/aggregate';
import { CollectionsOperation } from './operations/collections';
import type { IndexInformationOptions } from './operations/common_functions';
Expand Down Expand Up @@ -418,33 +417,6 @@ export class Db {
);
}

/**
* Add a user to the database
*
* @param username - The username for the new user
* @param passwordOrOptions - An optional password for the new user, or the options for the command
* @param options - Optional settings for the command
* @deprecated Use the createUser command in `db.command()` instead.
* @see https://www.mongodb.com/docs/manual/reference/command/createUser/
*/
async addUser(
username: string,
passwordOrOptions?: string | AddUserOptions,
options?: AddUserOptions
): Promise<Document> {
options =
options != null && typeof options === 'object'
? options
: passwordOrOptions != null && typeof passwordOrOptions === 'object'
? passwordOrOptions
: undefined;
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
return executeOperation(
this.client,
new AddUserOperation(this, username, password, resolveOptions(this, options))
);
}

/**
* Remove a user from a database
*
Expand Down
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ export type {
WithId,
WithoutId
} from './mongo_types';
export type { AddUserOptions, RoleSpecification } from './operations/add_user';
export type {
AggregateOperation,
AggregateOptions,
Expand Down Expand Up @@ -434,12 +433,7 @@ export type { RenameOptions } from './operations/rename';
export type { RunCommandOptions } from './operations/run_command';
export type { SearchIndexDescription } from './operations/search_indexes/create';
export type { SetProfilingLevelOptions } from './operations/set_profiling_level';
export type {
CollStats,
CollStatsOptions,
DbStatsOptions,
WiredTigerData
} from './operations/stats';
export type { DbStatsOptions } from './operations/stats';
export type {
ReplaceOptions,
UpdateOptions,
Expand Down
117 changes: 0 additions & 117 deletions src/operations/add_user.ts

This file was deleted.

Loading