title: How to get typegoose class model interface
body: <p>I want to create an abstraction for Mongo model functions. And searching how to reuse model interface from typegoose class.</p>
  
  <p>I want to have a function like: </p>
  
  <pre><code>import CountryModel, { Country } from '../../models/country/CountryModel'
  
  export async function saveCountry(country: Country): Promise&lt;Country&gt; {
    try {
      const res = await new CountryModel(country).save()
  
      return res.toObject()
    } catch (err) {
      console.log('Failed save country', country)
      throw err
    }
  }
  </code></pre>
  
  <p>CountryModel:</p>
  
  <pre><code>import mongoose from 'mongoose'
  import { prop, Typegoose } from 'typegoose'
  
  export class Country extends Typegoose {
    @prop({ required: true })
    name!: string
  
    @prop()
    code?: string
  
    @prop()
    flag?: string
  }
  
  const CountryModel = new Country().getModelForClass(Country, {
      existingMongoose: mongoose,
      schemaOptions: {collection: 'country'}
  })
  
  export default CountryModel
  </code></pre>
  
  <p>but when try pass object <code>{ name : 'country name', code: 'code', fag: 'flag' }</code> to <code>saveCountry</code> function I got error: </p>
  
  <blockquote>
    <p>2345: Argument of type '{ name: string; code: string; flag: string; }'
    is not assignable to parameter of type '...ing; }' is missing the
    following properties from type 'Country': getModelForClass,
    setModelForClass, buildSchema</p>
  </blockquote>