- findById(id, model, populateFields?): Promise<null | Document<any, any, any> & {
_id: ObjectId;
}>
-
Parameters
-
id: string
-
model: Model<Document<any, any, any>, {}, {}, {}, any>
-
populateFields: string[] = []
Returns Promise<null | Document<any, any, any> & {
_id: ObjectId;
}>
document if found
Find a document by id
Throws
mongoose error
Example
Example
if you want to populate fields in response