如何将mongoose.model(xxx,xxx)导出为TypeScript类

时间:2019-05-19 12:56:57

标签: typescript export mongoose-schema

是否可以将mongoose.model(xxx,xxx)导出为TypeScript类? 云你帮我吗? 非常感谢!!!!

store_entity.ts
export const StoreSchema: Schema = new Schema({
    name: {
        type: String
    }
}, {
        autoCreate: true,
        versionKey: false
    }
);

StoreSchema.index({ name: 1 }, { unique: true });

export const StoreEntity = mongoose.model('store', StoreSchema, 'store');
test.ts
import { StoreEntity } from './store_entity';

function display(storeEntity: StoreEntity) {
    console.log(storeEntity);
}

但是我有错误提示:

'StoreEntity' refers to a value, but is being used as a type here.ts(2749)

在test.ts

0 个答案:

没有答案