Compare commits
No commits in common. "308c9cb63db1486809f3142eefe25fa20253efdd" and "84ba3423e236cc6af2411f179c3ac88069d0af38" have entirely different histories.
308c9cb63d
...
84ba3423e2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navy.gif/wrappers",
|
||||
"version": "1.5.6",
|
||||
"version": "1.5.5",
|
||||
"description": "Various wrapper classes I use in my projects",
|
||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||
"author": "Navy.gif",
|
||||
|
@ -363,21 +363,13 @@ class MongoDB
|
||||
return this.#db.collection(coll).countDocuments(query);
|
||||
}
|
||||
|
||||
async ensureIndex (collection: string, index: IndexSpecification, options?: CreateIndexesOptions): Promise<void>
|
||||
async ensureIndex (collection: string, indices: IndexSpecification = [], options?: CreateIndexesOptions)
|
||||
{
|
||||
if (!this.#db)
|
||||
return Promise.reject(new Error('MongoDB not connected'));
|
||||
if (!(index instanceof Array))
|
||||
index = [ index ];
|
||||
await this.#db.collection(collection).createIndex(index, options);
|
||||
}
|
||||
|
||||
async ensureIndices (collection: string, indices: IndexSpecification[], options?: CreateIndexesOptions): Promise<void>
|
||||
{
|
||||
if (!this.#db)
|
||||
return Promise.reject(new Error('MongoDB not connected'));
|
||||
for (const index of indices)
|
||||
await this.ensureIndex(collection, index, options);
|
||||
throw new Error('MongoDB not connected');
|
||||
if (!(indices instanceof Array))
|
||||
indices = [ indices ];
|
||||
await this.#db.collection(collection).createIndex(indices, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user