Skip to content

Commit e85cede

Browse files
committed
feat(NODE-5432)!: remove addUser and collection.stats
1 parent fbb2db2 commit e85cede

File tree

7 files changed

+3
-411
lines changed

7 files changed

+3
-411
lines changed

Diff for: mongodb-legacy.d.ts

+3-48
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
// Dependencies (options, etc.)
2121
import type {
2222
AbstractCursorEvents,
23-
AddUserOptions,
2423
AggregateOptions,
2524
AnyBulkWriteOperation,
2625
BulkWriteOptions,
@@ -31,8 +30,6 @@ import type {
3130
ClientSessionOptions,
3231
CollectionInfo,
3332
CollectionOptions,
34-
CollStats,
35-
CollStatsOptions,
3633
CommandOperationOptions,
3734
CountDocumentsOptions,
3835
CountOptions,
@@ -93,10 +90,10 @@ import type {
9390
type NonConstructorKeys<T> = { [P in keyof T]: T[P] extends new () => any ? never : P }[keyof T];
9491
type NonConstructor<T> = Pick<T, NonConstructorKeys<T>>;
9592

96-
declare const Admin: new () => Omit<MDBAdmin, 'addUser' | 'buildInfo' | 'command' | 'listDatabases' | 'ping' | 'removeUser' | 'replSetGetStatus' | 'serverInfo' | 'serverStatus' | 'validateCollection'>;
93+
declare const Admin: new () => Omit<MDBAdmin, 'buildInfo' | 'command' | 'listDatabases' | 'ping' | 'removeUser' | 'replSetGetStatus' | 'serverInfo' | 'serverStatus' | 'validateCollection'>;
9794
declare const ChangeStream: new <TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>>() => Omit<MDBChangeStream<TSchema, TChange>, 'close' | 'hasNext' | 'next' | 'tryNext'>;
98-
declare const Collection: new <TSchema>() => Omit<MDBCollection<TSchema>, 'initializeUnorderedBulkOp' | 'initializeOrderedBulkOp' | 'bulkWrite'| 'count'| 'countDocuments'| 'estimatedDocumentCount'| 'createIndex'| 'createIndexes'| 'dropIndex'| 'dropIndexes'| 'deleteMany'| 'deleteOne'| 'distinct'| 'drop'| 'findOne'| 'findOneAndDelete'| 'findOneAndReplace'| 'findOneAndUpdate'| 'indexExists'| 'indexInformation'| 'indexes'| 'insertMany'| 'insertOne'| 'isCapped'| 'options'| 'rename'| 'replaceOne'| 'stats'| 'updateMany'| 'updateOne'| 'aggregate'| 'find'| 'listIndexes'| 'watch'>;
99-
declare const Db: new () => Omit<MDBDb, 'command' | 'addUser' | 'removeUser' | 'createCollection' | 'dropCollection' | 'createIndex' | 'dropDatabase' | 'indexInformation' | 'profilingLevel' | 'setProfilingLevel' | 'renameCollection' | 'stats' | 'collections' | 'collection' | 'admin' | 'aggregate' | 'listCollections' | 'watch'>;
95+
declare const Collection: new <TSchema>() => Omit<MDBCollection<TSchema>, 'initializeUnorderedBulkOp' | 'initializeOrderedBulkOp' | 'bulkWrite'| 'count'| 'countDocuments'| 'estimatedDocumentCount'| 'createIndex'| 'createIndexes'| 'dropIndex'| 'dropIndexes'| 'deleteMany'| 'deleteOne'| 'distinct'| 'drop'| 'findOne'| 'findOneAndDelete'| 'findOneAndReplace'| 'findOneAndUpdate'| 'indexExists'| 'indexInformation'| 'indexes'| 'insertMany'| 'insertOne'| 'isCapped'| 'options'| 'rename'| 'replaceOne'| 'updateMany'| 'updateOne'| 'aggregate'| 'find'| 'listIndexes'| 'watch'>;
96+
declare const Db: new () => Omit<MDBDb, 'command' | 'removeUser' | 'createCollection' | 'dropCollection' | 'createIndex' | 'dropDatabase' | 'indexInformation' | 'profilingLevel' | 'setProfilingLevel' | 'renameCollection' | 'stats' | 'collections' | 'collection' | 'admin' | 'aggregate' | 'listCollections' | 'watch'>;
10097
declare const GridFSBucket: new (db: LegacyDb, options: GridFSBucketOptions) => Omit<NonConstructor<MDBGridFSBucket>, 'delete' | 'rename' | 'drop' | 'find'>;
10198
declare const MongoClient: new (url: string, options?: MongoClientOptions) => Omit<NonConstructor<MDBMongoClient>, 'connect' | 'close' | 'db' | 'watch' | 'withSession' | 'startSession'>;
10299
declare const ClientSession: new () => Omit<MDBClientSession, 'endSession' | 'abortTransaction' | 'commitTransaction' | 'withTransaction'>
@@ -156,22 +153,6 @@ declare class LegacyAdmin extends Admin {
156153
ping(callback: Callback<Document>): void;
157154
ping(options: CommandOperationOptions): Promise<Document>;
158155
ping(options: CommandOperationOptions, callback: Callback<Document>): void;
159-
/**
160-
* Add a user to the database
161-
*
162-
* @param username - The username for the new user
163-
* @param password - An optional password for the new user
164-
* @param options - Optional settings for the command
165-
* @param callback - An optional callback, a Promise will be returned if none is provided
166-
*/
167-
addUser(username: string): Promise<Document>;
168-
addUser(username: string, callback: Callback<Document>): void;
169-
addUser(username: string, password: string): Promise<Document>;
170-
addUser(username: string, password: string, callback: Callback<Document>): void;
171-
addUser(username: string, options: AddUserOptions): Promise<Document>;
172-
addUser(username: string, options: AddUserOptions, callback: Callback<Document>): void;
173-
addUser(username: string, password: string, options: AddUserOptions): Promise<Document>;
174-
addUser(username: string, password: string, options: AddUserOptions, callback: Callback<Document>): void;
175156
/**
176157
* Remove a user from a database
177158
*
@@ -637,16 +618,6 @@ declare class LegacyCollection<TSchema extends Document = Document> extends Coll
637618
indexes(callback: Callback<Document[]>): void;
638619
indexes(options: IndexInformationOptions): Promise<Document[]>;
639620
indexes(options: IndexInformationOptions, callback: Callback<Document[]>): void;
640-
/**
641-
* Get all the collection statistics.
642-
*
643-
* @param options - Optional settings for the command
644-
* @param callback - An optional callback, a Promise will be returned if none is provided
645-
*/
646-
stats(): Promise<CollStats>;
647-
stats(callback: Callback<CollStats>): void;
648-
stats(options: CollStatsOptions): Promise<CollStats>;
649-
stats(options: CollStatsOptions, callback: Callback<CollStats>): void;
650621
/**
651622
* Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation.
652623
*
@@ -868,22 +839,6 @@ declare class LegacyDb extends Db {
868839
createIndex(name: string, indexSpec: IndexSpecification, callback?: Callback<string>): void;
869840
createIndex(name: string, indexSpec: IndexSpecification, options: CreateIndexesOptions): Promise<string>;
870841
createIndex(name: string, indexSpec: IndexSpecification, options: CreateIndexesOptions, callback: Callback<string>): void;
871-
/**
872-
* Add a user to the database
873-
*
874-
* @param username - The username for the new user
875-
* @param password - An optional password for the new user
876-
* @param options - Optional settings for the command
877-
* @param callback - An optional callback, a Promise will be returned if none is provided
878-
*/
879-
addUser(username: string): Promise<Document>;
880-
addUser(username: string, callback: Callback<Document>): void;
881-
addUser(username: string, password: string): Promise<Document>;
882-
addUser(username: string, password: string, callback: Callback<Document>): void;
883-
addUser(username: string, options: AddUserOptions): Promise<Document>;
884-
addUser(username: string, options: AddUserOptions, callback: Callback<Document>): void;
885-
addUser(username: string, password: string, options: AddUserOptions): Promise<Document>;
886-
addUser(username: string, password: string, options: AddUserOptions, callback: Callback<Document>): void;
887842
/**
888843
* Remove a user from a database
889844
*

Diff for: src/legacy_wrappers/admin.js

-19
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@ Object.defineProperty(module.exports, '__esModule', { value: true });
77

88
module.exports.makeLegacyAdmin = function (baseClass) {
99
class LegacyAdmin extends baseClass {
10-
addUser(username, password, options, callback) {
11-
callback =
12-
typeof callback === 'function'
13-
? callback
14-
: typeof options === 'function'
15-
? options
16-
: typeof password === 'function'
17-
? password
18-
: undefined;
19-
options =
20-
options != null && typeof options === 'object'
21-
? options
22-
: password != null && typeof password === 'object'
23-
? password
24-
: undefined;
25-
password = typeof password === 'string' ? password : undefined;
26-
return maybeCallback(super.addUser(username, password, options), callback);
27-
}
28-
2910
buildInfo(options, callback) {
3011
callback =
3112
typeof callback === 'function'

Diff for: src/legacy_wrappers/collection.js

-11
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,6 @@ module.exports.makeLegacyCollection = function (baseClass) {
307307
return maybeCallback(super.replaceOne(filter, replacement, options), callback);
308308
}
309309

310-
stats(options, callback) {
311-
callback =
312-
typeof callback === 'function'
313-
? callback
314-
: typeof options === 'function'
315-
? options
316-
: undefined;
317-
options = typeof options !== 'function' ? options : undefined;
318-
return maybeCallback(super.stats(options), callback);
319-
}
320-
321310
updateMany(filter, update, options, callback) {
322311
callback =
323312
typeof callback === 'function'

Diff for: src/legacy_wrappers/db.js

-20
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@ module.exports.makeLegacyDb = function (baseClass) {
1818
return maybeCallback(super.command(command, options), callback);
1919
}
2020

21-
// Async APIs
22-
addUser(username, password, options, callback) {
23-
callback =
24-
typeof callback === 'function'
25-
? callback
26-
: typeof options === 'function'
27-
? options
28-
: typeof password === 'function'
29-
? password
30-
: undefined;
31-
options =
32-
options != null && typeof options === 'object'
33-
? options
34-
: password != null && typeof password === 'object'
35-
? password
36-
: undefined;
37-
password = typeof password === 'string' ? password : undefined;
38-
return maybeCallback(super.addUser(username, password, options), callback);
39-
}
40-
4121
removeUser(username, options, callback) {
4222
callback =
4323
typeof callback === 'function'

Diff for: test/tools/api.js

-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const api = [
2828
// Super class of cursors, we do not directly override these but override them in the inherited classes
2929
...commonCursorApis.flatMap(({ method, returnType, possibleCallbackPositions }) => cursorClasses.map(cursorClass => ({ className: cursorClass, method, returnType, possibleCallbackPositions }))),
3030

31-
{ className: 'Admin', method: 'addUser', returnType: 'Promise<Document>', special: 'addUser takes 4 arguments: [username, password, options, callback] the last 3 are optional, unlike other functions with this length password needs to be filtered to only be a string, this is the only case where we make a decision to pass an argument based on its type (instead of what type it is not)' },
3231
{ className: 'Admin', method: 'buildInfo', returnType: 'Promise<Document>' },
3332
{ className: 'Admin', method: 'command', returnType: 'Promise<Document>' },
3433
{ className: 'Admin', method: 'listDatabases', returnType: 'Promise<ListDatabasesResult>' },
@@ -88,7 +87,6 @@ const api = [
8887
{ className: 'Collection', method: 'options', returnType: 'Promise<Document>' },
8988
{ className: 'Collection', method: 'rename', returnType: 'Promise<Collection>', changesPromise: true },
9089
{ className: 'Collection', method: 'replaceOne', returnType: 'Promise<UpdateResult | Document>' },
91-
{ className: 'Collection', method: 'stats', returnType: 'Promise<CollStats>' },
9290
{ className: 'Collection', method: 'updateMany', returnType: 'Promise<UpdateResult | Document>' },
9391
{ className: 'Collection', method: 'updateOne', returnType: 'Promise<UpdateResult>' },
9492
{ className: 'Collection', method: 'initializeOrderedBulkOp', returnType: 'OrderedBulkOperation', notAsync: true },
@@ -98,7 +96,6 @@ const api = [
9896
{ className: 'Collection', method: 'listIndexes', returnType: 'ListIndexesCursor', notAsync: true },
9997
{ className: 'Collection', method: 'watch', returnType: 'ChangeStream', notAsync: true },
10098

101-
{ className: 'Db', method: 'addUser', returnType: 'Promise<Document>', special: 'see Admin.addUser' },
10299
{ className: 'Db', method: 'collections', returnType: 'Promise<Collection[]>', changesPromise: true },
103100
{ className: 'Db', method: 'command', returnType: 'Promise<Document>' },
104101
{ className: 'Db', method: 'createCollection', returnType: 'Promise<Collection<TSchema>>', changesPromise: true },

Diff for: test/unit/legacy_wrappers/admin.test.js

-163
This file was deleted.

0 commit comments

Comments
 (0)