Skip to main content

Default Classes

This Guide contains all default classes Typegoose provides.

note

All properties provided are just types to show which are available from Mongoose, or stated otherwise.

TimeStamps

The TimeStamps class provides the following fields:

Field NameType
createdAtDate
updatedAtDate

And also applies the following schemaOptions:

Field NameValue
timestampstrue

Base

The Base Interface provides the following fields:

Field NameType
_idThe chosen ID-Type, by default mongoose.Types.ObjectId
idstring
tip

Note that @prop() should not be used on the implemented properties, unless you specifically want to overwrite default behavior or change the _id type.

Example Usage:
This only works with typegoose 8.0.0+

class Something implements Base {
public _id!: ObjectId
public id!: string;
}
// Base can also be used together with other classes
class Something extends TimeStamps implements Base {
// ... properties to implement
}