mongodb
Advanced tools
Comparing version 6.5.0-dev.20240411.sha.ddd1e81 to 6.5.0-dev.20240412.sha.232bf3c
@@ -411,9 +411,7 @@ "use strict"; | ||
} | ||
/** | ||
* Retrieves this collections index info. | ||
* | ||
* @param options - Optional settings for the command | ||
*/ | ||
async indexInformation(options) { | ||
return await this.indexes({ ...options, full: options?.full ?? false }); | ||
return await this.indexes({ | ||
...options, | ||
full: options?.full ?? false | ||
}); | ||
} | ||
@@ -467,7 +465,2 @@ /** | ||
} | ||
/** | ||
* Retrieve all the indexes on the collection. | ||
* | ||
* @param options - Optional settings for the command | ||
*/ | ||
async indexes(options) { | ||
@@ -480,3 +473,2 @@ const indexes = await this.listIndexes(options).toArray(); | ||
const object = Object.fromEntries(indexes.map(({ name, key }) => [name, Object.entries(key)])); | ||
// @ts-expect-error TODO(NODE-6029): fix return type of `indexes()` and `indexInformation()` | ||
return object; | ||
@@ -483,0 +475,0 @@ } |
@@ -306,8 +306,2 @@ "use strict"; | ||
} | ||
/** | ||
* Retrieves this collections index info. | ||
* | ||
* @param name - The name of the collection. | ||
* @param options - Optional settings for the command | ||
*/ | ||
async indexInformation(name, options) { | ||
@@ -314,0 +308,0 @@ return await this.collection(name).indexInformation((0, utils_1.resolveOptions)(this, options)); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TopologyDescription = void 0; | ||
const bson_1 = require("../bson"); | ||
const WIRE_CONSTANTS = require("../cmap/wire_protocol/constants"); | ||
@@ -239,2 +240,11 @@ const error_1 = require("../error"); | ||
} | ||
/** | ||
* Returns a JSON-serializable representation of the TopologyDescription. This is primarily | ||
* intended for use with JSON.stringify(). | ||
* | ||
* This method will not throw. | ||
*/ | ||
toJSON() { | ||
return bson_1.EJSON.serialize(this); | ||
} | ||
} | ||
@@ -241,0 +251,0 @@ exports.TopologyDescription = TopologyDescription; |
{ | ||
"name": "mongodb", | ||
"version": "6.5.0-dev.20240411.sha.ddd1e81", | ||
"version": "6.5.0-dev.20240412.sha.232bf3c", | ||
"description": "The official MongoDB driver for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -55,3 +55,4 @@ import { type BSONSerializeOptions, type Document, resolveBSONOptions } from './bson'; | ||
IndexDescription, | ||
IndexDirection, | ||
IndexDescriptionCompact, | ||
IndexDescriptionInfo, | ||
IndexInformationOptions, | ||
@@ -699,4 +700,19 @@ IndexSpecification, | ||
*/ | ||
async indexInformation(options?: IndexInformationOptions): Promise<Document> { | ||
return await this.indexes({ ...options, full: options?.full ?? false }); | ||
indexInformation( | ||
options: IndexInformationOptions & { full: true } | ||
): Promise<IndexDescriptionInfo[]>; | ||
indexInformation( | ||
options: IndexInformationOptions & { full?: false } | ||
): Promise<IndexDescriptionCompact>; | ||
indexInformation( | ||
options: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>; | ||
indexInformation(): Promise<IndexDescriptionCompact>; | ||
async indexInformation( | ||
options?: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]> { | ||
return await this.indexes({ | ||
...options, | ||
full: options?.full ?? false | ||
}); | ||
} | ||
@@ -805,4 +821,12 @@ | ||
*/ | ||
async indexes(options?: IndexInformationOptions): Promise<Document[]> { | ||
const indexes = await this.listIndexes(options).toArray(); | ||
indexes(options: IndexInformationOptions & { full?: true }): Promise<IndexDescriptionInfo[]>; | ||
indexes(options: IndexInformationOptions & { full: false }): Promise<IndexDescriptionCompact>; | ||
indexes( | ||
options: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>; | ||
indexes(options?: ListIndexesOptions): Promise<IndexDescriptionInfo[]>; | ||
async indexes( | ||
options?: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]> { | ||
const indexes: IndexDescriptionInfo[] = await this.listIndexes(options).toArray(); | ||
const full = options?.full ?? true; | ||
@@ -813,8 +837,6 @@ if (full) { | ||
const object: Record< | ||
string, | ||
Array<[name: string, direction: IndexDirection]> | ||
> = Object.fromEntries(indexes.map(({ name, key }) => [name, Object.entries(key)])); | ||
const object: IndexDescriptionCompact = Object.fromEntries( | ||
indexes.map(({ name, key }) => [name, Object.entries(key)]) | ||
); | ||
// @ts-expect-error TODO(NODE-6029): fix return type of `indexes()` and `indexInformation()` | ||
return object; | ||
@@ -1081,2 +1103,3 @@ } | ||
typeof indexNameOrOptions === 'object' ? indexNameOrOptions : options == null ? {} : options; | ||
const indexName = | ||
@@ -1083,0 +1106,0 @@ indexNameOrOptions == null |
@@ -6,3 +6,3 @@ import type { Collection } from '../collection'; | ||
/** @public */ | ||
export type ListSearchIndexesOptions = AggregateOptions; | ||
export type ListSearchIndexesOptions = Omit<AggregateOptions, 'readConcern' | 'writeConcern'>; | ||
@@ -9,0 +9,0 @@ /** @public */ |
@@ -28,2 +28,4 @@ import { Admin } from './admin'; | ||
type CreateIndexesOptions, | ||
type IndexDescriptionCompact, | ||
type IndexDescriptionInfo, | ||
type IndexInformationOptions, | ||
@@ -489,3 +491,19 @@ type IndexSpecification | ||
*/ | ||
async indexInformation(name: string, options?: IndexInformationOptions): Promise<Document> { | ||
indexInformation( | ||
name: string, | ||
options: IndexInformationOptions & { full: true } | ||
): Promise<IndexDescriptionInfo[]>; | ||
indexInformation( | ||
name: string, | ||
options: IndexInformationOptions & { full?: false } | ||
): Promise<IndexDescriptionCompact>; | ||
indexInformation( | ||
name: string, | ||
options: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>; | ||
indexInformation(name: string): Promise<IndexDescriptionCompact>; | ||
async indexInformation( | ||
name: string, | ||
options?: IndexInformationOptions | ||
): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]> { | ||
return await this.collection(name).indexInformation(resolveOptions(this, options)); | ||
@@ -492,0 +510,0 @@ } |
@@ -474,2 +474,4 @@ import { Admin } from './admin'; | ||
IndexDescription, | ||
IndexDescriptionCompact, | ||
IndexDescriptionInfo, | ||
IndexDirection, | ||
@@ -476,0 +478,0 @@ IndexSpecification, |
@@ -218,2 +218,14 @@ import type { Document } from '../bson'; | ||
/** | ||
* @public | ||
* The index information returned by the listIndexes command. https://www.mongodb.com/docs/manual/reference/command/listIndexes/#mongodb-dbcommand-dbcmd.listIndexes | ||
*/ | ||
export type IndexDescriptionInfo = Omit<IndexDescription, 'key' | 'version'> & { | ||
key: { [key: string]: IndexDirection }; | ||
v?: IndexDescription['version']; | ||
} & Document; | ||
/** @public */ | ||
export type IndexDescriptionCompact = Record<string, [name: string, direction: IndexDirection][]>; | ||
/** | ||
* @internal | ||
@@ -220,0 +232,0 @@ * |
@@ -1,2 +0,2 @@ | ||
import type { ObjectId } from '../bson'; | ||
import { EJSON, type ObjectId } from '../bson'; | ||
import * as WIRE_CONSTANTS from '../cmap/wire_protocol/constants'; | ||
@@ -345,2 +345,12 @@ import { type MongoError, MongoRuntimeError } from '../error'; | ||
} | ||
/** | ||
* Returns a JSON-serializable representation of the TopologyDescription. This is primarily | ||
* intended for use with JSON.stringify(). | ||
* | ||
* This method will not throw. | ||
*/ | ||
toJSON() { | ||
return EJSON.serialize(this); | ||
} | ||
} | ||
@@ -347,0 +357,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2986331
61553