小编eps*_*lon的帖子

如何在 NestJS 中插入具有 OneToMany 关系的实体?

在 typeorm 官方文档https://typeorm.io/#/many-to-one-one-to-many-relations 中描述了如何执行此操作。但是我不能在 NestJS 中使用Repositoryinsert方法做同样的事情。

我已经写了这些实体(省略了其他列)

@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)

typeorm nestjs

7
推荐指数
1
解决办法
1万
查看次数

Angular 6中的两个具有公共组件的延迟加载模块

我有一个像

---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)

stackblitz https://stackblitz.com/github/ms-dosx86/films

typescript angular

6
推荐指数
1
解决办法
1028
查看次数

如何将所有路由重定向到 nest.js 中的 index.html (Angular)?

我正在制作 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'). 请帮忙

javascript node.js express typescript nestjs

5
推荐指数
1
解决办法
7096
查看次数

bash脚本中$1和“$1”有什么区别?

例子

while [ -n "$1" ]
do
  something
done
Run Code Online (Sandbox Code Playgroud)

我可以写$1代替吗"$1"user=alexander和和有什么区别 user="alexander"?谢谢

bash

1
推荐指数
1
解决办法
8540
查看次数

标签 统计

nestjs ×2

typescript ×2

angular ×1

bash ×1

express ×1

javascript ×1

node.js ×1

typeorm ×1