getClassForDocument
Typings:
function getClassForDocument(document: mongoose.Document): NewableFunction | undefined
Parameters:
Name | Type | Description |
---|---|---|
document Required | mongoose.Document | The Document to get the Class from |
getClassForDocument
is used to get a Class from a document (which either has a .typegooseName
function or property), this function is a more specific case of getClass
.
note
This function only works if the schema has been created with buildSchema
or a property / function has been manually added.
caution
This Function has been removed in typegoose 10.0, use getClass
instead.
Example
class Kitten {
@prop()
public name?: string;
}
const KittenModel = getModelForClass(Kitten);
const doc = new KittenModel();
getClassForDocument(doc) === Kitten; // should be "true"