在 typeorm 官方文档https://typeorm.io/#/many-to-one-one-to-many-relations 中描述了如何执行此操作。但是我不能在 NestJS 中使用Repository和insert方法做同样的事情。
我已经写了这些实体(省略了其他列)
@Entity()
export class News {
@OneToMany(type => NewsImage, image => image.news)
public images: NewsImage[];
}
@Entity()
export class NewsImage {
@ManyToOne(type => News, news => news.images)
public news: News;
}
Run Code Online (Sandbox Code Playgroud)
我试过这样的事情
function first() {
const news = new News();
const image = new NewsImage();
news.images = [ image ];
return from(this.newsRepo.insert(news))
.pipe(
switchMap(() => this.imageRepo.insert(image)),
);
}
function second() {
const news = new News();
const image …Run Code Online (Sandbox Code Playgroud) 我有一个像
---app.module
-------child1.module
-------child2.module
Run Code Online (Sandbox Code Playgroud)
并且我app-film在两个子模块中都使用了1个公共组件(),我在中声明了一个app.module,但是Angular仍然显示错误
Can't bind to 'film' since it isn't a known property of 'app-film'.
1. If 'app-film' is an Angular component and it has 'film' input, then verify that it is part of this module.
2. If 'app-film' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
Run Code Online (Sandbox Code Playgroud)
我正在制作 Angular + NestJS 应用程序,我想index.html为所有路由发送文件。
主文件
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useStaticAssets(join(__dirname, '..', 'frontend', 'dist', 'my-app'));
app.setBaseViewsDir(join(__dirname, '..', 'frontend', 'dist', 'my-app'));
await app.listen(port);
}
Run Code Online (Sandbox Code Playgroud)
app.controller.ts
@Controller('*')
export class AppController {
@Get()
@Render('index.html')
root() {
return {};
}
}
Run Code Online (Sandbox Code Playgroud)
当我打开时它工作正常localhost:3000/,但是如果我打开localhost:3000/some_route服务器会出现500 internal error并说Can not find html module。我在搜索为什么我会收到这个错误,每个人都说set default view engine like ejs or pug,但我不想使用某些引擎,我只想发送由 angular 构建的纯 html,而不像res.sendFile('path_to_file'). 请帮忙
例子
while [ -n "$1" ]
do
something
done
Run Code Online (Sandbox Code Playgroud)
我可以写$1代替吗"$1"?user=alexander和和有什么区别
user="alexander"?谢谢