Database Utilities
Contains utilities related to database operations.
Get Collection
getCollection<
T
>(db
,collection
):Model
<T
>
Function
Gets a Mongoose model for a specific collection getCollection
Example
typescript
const userModel = getCollection('myapp', 'users');
const users = await userModel.find();
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
db | string | Database name |
collection | string | Collection name |
Returns
Model
<T
>
Mongoose model for the collection
Throws
If the collection doesn't exist