Skip to main content



What happened to the original author?

A: The original author szokodiakos (github name) has abandoned the project, but might look into it again at some time.

Is this Project still active?

A: Yes it is, but not on the main repository anymore because of What happened to the original author? and Github Permissions (TL;DR: a collaborator cannot add another collaborator, only the owner can)

Why is the package now released in another package?

(context: from typegoose to @typegoose/typegoose)
A: Because of a Repository Switch (reasons) and because a name cannot be used by multiple packages, except if it is scoped.

Why @typegoose/typegoose

A: Because I (hasezoey) don't have permissions over the old typegoose repository and I don't want to touch the old npm package. It is a typical forking and continuation of an OSS project.


Why does new Model({}) not have types?

A: Since around mongoose 6.0.0, new Model() and Model.create() have types, but they are not enforced (as in they will be suggested, but will not error if not present / other unknown properties are present).

Do all Classes get compiled to their own mongoose.Schema?

A: Yes, all classes compiled through typegoose (like type: () => SubClass, or by reflection) will be their own mongoose.Schema.

This means that the following is equal:

// Native Mongoose
const subSchema = new mongoose.Schema({ someprop: { type: String } });
const mainSchema = new mongoose.Schema({
subDoc: subSchema

// Typegoose
class Sub {
public someprop: string;

class Main {
public subDoc: Sub; // by reflection, not explicitly defining option "type"
// OR
@prop({ type: () => Sub }) // defining option "type" explicitly
public subDoc: Sub;

There is also a option to not use sub-classes, called the Passthrough class, but it is not recommended to be used.

Edge Cases

I want to the return document with property id instead of _id

Mongoose automatically adds a virtual named id, use the following for type definitions if it does not already exist:

class Cat {
id: mongoose.Types.ObjectId;
_id: mongoose.Types.ObjectId;