我正在使用Angular for ui用Electron开发一个桌面应用程序,我想使用sequelize-typescript连接到数据库,但是创建sequelize实例会出现以下错误。可以在sangelize中使用sequelize-typescript吗?
TypeError: sequelize_typescript__WEBPACK_IMPORTED_MODULE_3__.Sequelize is not a constructor
at AppComponent.index4 (app.component.ts:126)
at new AppComponent (app.component.ts:29)
at NodeInjectorFactory.AppComponent_Factory [as factory] (app.component.ts:136)
at getNodeInjectable (core.js:6025)
at instantiateRootComponent (core.js:12788)
at createRootComponent (core.js:26484)
at ComponentFactory$1.create (core.js:34106)
at ApplicationRef.bootstrap (core.js:43103)
at core.js:42691
at Array.forEach (<anonymous>)
我这样导入:
import Person from './lib/model/Person';
import { Component, OnInit } from '@angular/core';
import { Sequelize, DataType } from 'sequelize-typescript';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'wi2';
ngOnInit() {
const database = new Sequelize({
database: 'test1',
dialect: 'postgres',
username: 'test',
password: 'test'
});
database.authenticate()
.then(() => console.log("aut"))
.catch(() => console.log("no aut"))
database.addModels([Person])
.then(() => console.log("models added"))
.catch((err) => console.log(err));
}
constructor() { }
}