deno.land / x / mongoose@6.7.5 / types / indexes.d.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
declare module 'mongoose' { import mongodb = require('mongodb');
/** * Makes the indexes in MongoDB match the indexes defined in every model's * schema. This function will drop any indexes that are not defined in * the model's schema except the `_id` index, and build any indexes that * are in your schema but not in MongoDB. */ function syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>; function syncIndexes(options: SyncIndexesOptions | null, callback: Callback<ConnectionSyncIndexesResult>): void;
interface IndexManager { /** * Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex) * function. */ createIndexes(options: mongodb.CreateIndexesOptions, callback: CallbackWithoutResult): void; createIndexes(callback: CallbackWithoutResult): void; createIndexes(options?: mongodb.CreateIndexesOptions): Promise<void>;
/** * Does a dry-run of Model.syncIndexes(), meaning that * the result of this function would be the result of * Model.syncIndexes(). */ diffIndexes(options: Record<string, unknown> | null, callback: Callback<IndexesDiff>): void diffIndexes(callback: Callback<IndexesDiff>): void diffIndexes(options?: Record<string, unknown>): Promise<IndexesDiff>
/** * Sends `createIndex` commands to mongo for each index declared in the schema. * The `createIndex` commands are sent in series. */ ensureIndexes(options: mongodb.CreateIndexesOptions, callback: CallbackWithoutResult): void; ensureIndexes(callback: CallbackWithoutResult): void; ensureIndexes(options?: mongodb.CreateIndexesOptions): Promise<void>;
/** * Lists the indexes currently defined in MongoDB. This may or may not be * the same as the indexes defined in your schema depending on whether you * use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you * build indexes manually. */ listIndexes(callback: Callback<Array<any>>): void; listIndexes(): Promise<Array<any>>;
/** * Makes the indexes in MongoDB match the indexes defined in this model's * schema. This function will drop any indexes that are not defined in * the model's schema except the `_id` index, and build any indexes that * are in your schema but not in MongoDB. */ syncIndexes(options: SyncIndexesOptions | null, callback: Callback<Array<string>>): void; syncIndexes(options?: SyncIndexesOptions): Promise<Array<string>>; }
interface IndexesDiff { /** Indexes that would be created in mongodb. */ toCreate: Array<any> /** Indexes that would be dropped in mongodb. */ toDrop: Array<any> }
type IndexDirection = 1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text' | 'ascending' | 'asc' | 'descending' | 'desc'; type IndexDefinition = Record<string, IndexDirection>;
interface SyncIndexesOptions extends mongodb.CreateIndexesOptions { continueOnError?: boolean } type ConnectionSyncIndexesResult = Record<string, OneCollectionSyncIndexesResult>; type OneCollectionSyncIndexesResult = Array<string> & mongodb.MongoServerError;
interface IndexOptions extends mongodb.CreateIndexesOptions { /** * `expires` utilizes the `ms` module from [guille](https://github.com/guille/) allowing us to use a friendlier syntax: * * @example * ```js * const schema = new Schema({ prop1: Date }); * * // expire in 24 hours * schema.index({ prop1: 1 }, { expires: 60*60*24 }) * * // expire in 24 hours * schema.index({ prop1: 1 }, { expires: '24h' }) * * // expire in 1.5 hours * schema.index({ prop1: 1 }, { expires: '1.5h' }) * * // expire in 7 days * schema.index({ prop1: 1 }, { expires: '7d' }) * ``` */ expires?: number | string; weights?: Record<string, number>; }}
mongoose

Version Info

Tagged at
a year ago