Function addModelToTypegoose

  • Add a Class-Model Pair to the Typegoose Cache This can be used to add custom Models to Typegoose, with the type information of "cl" Note: no guarrantee that the type information is fully correct when used manually

    Type Parameters

    Parameters

    • model: mongoose.Model<any, {}, {}, {}, any, any>

      The Model to store

    • cl: U

      The Class to store

    • Optional options: {
          disableCaching?: boolean;
          existingConnection?: any;
          existingMongoose?: mongoose;
      }

      Overwrite existingMongoose or existingConnection

      Optional
      • Optional disableCaching?: boolean
      • Optional existingConnection?: any
      • Optional existingMongoose?: mongoose

    Returns ReturnModelType<U, QueryHelpers>

    Example

    class ClassName {}

    const schema = buildSchema(ClassName);
    // modifications to the schema can be done
    const model = addModelToTypegoose(mongoose.model("Name", schema), ClassName);

Generated using TypeDoc