【发布时间】:2021-06-24 02:09:15
【问题描述】:
错误信息:
类型参数 '{ 只读实体:只读 [typeof Post];只读数据库名称:“lireddit”;只读类型:“postgresql”;只读调试:布尔值; }' 不可分配给“配置
index.ts:
import { MikroORM } from '@mikro-orm/core';
import { __prod__ } from './constants';
import { Post } from './entities/Post';
import mikroConfig from './mikro-orm.config';
const main = async() => {
const orm = await MikroORM.init(mikroConfig);
const post = orm.em.create(Post, {title:'ez az első posztom hehe'})
await orm.em.persistAndFlush(post)
}
main().catch((err) => {
console.error(err)
})
还有 mikro-orm.config.ts:
import { Post } from "./entities/Post";
import { __prod__ } from "./constants";
export default {
entities:[Post],
dbName: "lireddit",
type: "postgresql",
debug : !__prod__,
} as const;
谢谢你的帮助,太痛苦了
【问题讨论】:
-
来自 Ben Awad 的“全栈 React GraphQL TypeScript 教程”。 youtu.be/I6ypD7qv3Z8?t=1499 谢谢你的发帖——我也被这个绊倒了。
标签: typescript typescript-typings mikro-orm