Monday, 17 April 2017

How to declare a customized mongoose data model

Hi I am having a problem to declare a customized data model in mongoose. The following is what I am trying to do:

I try to declare a data type inside ParentModel.ts...But it said cannot find name ChildModel

Can someone help me with this?

ChildModel.ts

import mongoose = require("mongoose");

export interface ChildModel extends mongoose.Document {
    address1: string;
    address2: string;
    current: boolean;
}

ParentModel.ts

import mongoose = require("mongoose");
import ChildModel = require("./ChildModel");
export interface ParentModel extends mongoose.Document {
    firstName: string;
    lastName: string;
    age: number;
    contact: ChildModel;
}



via Mathers

No comments:

Post a Comment