admin管理员组文章数量:1399997
I have these models: . So I've created an abstract Realty class and Apartment entity class which inherits Realty.
Data source:
import "reflect-metadata";
import { DataSource } from "typeorm";
import Address from "./entity/Address";
import Building from "./entity/Building";
import Item from "./entity/Item";
import Terms from "./entity/Terms";
import Apartment from "./entity/Apartment";
import Listing from "./entity/Listing";
export const AppDataSource = new DataSource({
type: "sqlite",
database: "database.sqlite",
synchronize: true,
logging: false,
entities: [Address, Building, Item, Terms, Apartment, Listing],
migrations: [],
subscribers: [],
});
import { AppDataSource } from "./data-source";
AppDataSource.initialize()
.then(async () => {
console.log("Inserting a new user into the database...");
})
.catch((error) => console.log(error));
When I run src/index.ts
, I get these errors:
PS D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings> npx tsx src/index.ts
TypeError: Cannot read properties of undefined (reading 'ownColumns')
at <anonymous> (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\metadata-builder\src\metadata-builder\EntityMetadataBuilder.ts:541:64)
at Array.map (<anonymous>)
at EntityMetadataBuilderputeEntityMetadataStep1 (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\metadata-builder\src\metadata-builder\EntityMetadataBuilder.ts:538:14)
at <anonymous> (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\metadata-builder\src\metadata-builder\EntityMetadataBuilder.ts:145:22)
at Array.forEach (<anonymous>)
at EntityMetadataBuilder.build (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\metadata-builder\src\metadata-builder\EntityMetadataBuilder.ts:144:14)
at ConnectionMetadataBuilder.buildEntityMetadatas (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\connection\src\connection\ConnectionMetadataBuilder.ts:106:11)
at async DataSource.buildMetadatas (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\data-source\src\data-source\DataSource.ts:712:13)
at async DataSource.initialize (D:\Documents\_Igor\Projekti\_Master\express-typeorm-real-estate-listings\node_modules\typeorm\data-source\src\data-source\DataSource.ts:263:13)
Why do I get this error? Are abstract models not supposed to create a table in the DB?
本文标签:
版权声明:本文标题:typescript - Apartment inherits Realty. TypeError: Cannot read properties of undefined (reading 'ownColumns') - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744236641a2596586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论