小编Mat*_*ndt的帖子

自引用多对多关系类型ORM

我刚刚开始使用 TypeORM,我正在努力使以下关系起作用:

User->Friends,而朋友也是用户对象。但是,我的 getter、getFriends 和 getFriendsInverse 正在工作;我现在想区分这两者。换句话说; 当我执行 mysql join 时,我不想对朋友进行左联接,而对 inverseFriends 进行另一个联接。

getter getFriends() 需要返回所有朋友,无论我在对象的“哪一边”。

那有意义吗?

这是我的模型定义:

getFriends() {
    // This method should also return inverseFriends;
    // I do not want to return the concat version; this should
    // happen on the database/orm level
    // So I dont want: this.friends.concat(this.inverseFriends) 
    return this.friends;
}

@ManyToMany(type => User, user => user.friendsInverse, {
    cascadeInsert: false,
    cascadeUpdate: false,
})
@JoinTable()
friends = [];

@ManyToMany(type => User, user => user.friends, {
    cascadeInsert: true,
    cascadeUpdate: …
Run Code Online (Sandbox Code Playgroud)

mysql orm node.js typeorm

11
推荐指数
2
解决办法
9778
查看次数

NestJS:复制资源在 Linux 上不起作用

我正在开发一个 NestJS 项目,复制我的资源在我的 Mac 上工作得很好。但是,一旦我将其docker化,它就无法工作。

嵌套-cli.json

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "assets": [
      "**/*.hbs",
      "**/*.css",
      "**/*.jpg",
      "**/*.png",
      "**/*.jpeg"
    ],
    "watchAssets": true
  }
}
Run Code Online (Sandbox Code Playgroud)

Dockerfile:

FROM mhart/alpine-node:latest

RUN npm install pm2 -g

COPY backend /var/www/backend
COPY process.json /var/www
WORKDIR /var/www

#RUN npm i -g @nestjs/cli (tried with and w/out -> no difference)
RUN cd ./backend && npm i --legacy-peer-deps && npm run build

# Expose ports
EXPOSE 80

CMD ["pm2-runtime", "./backend/main"]
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true, …
Run Code Online (Sandbox Code Playgroud)

node.js docker dockerfile nestjs nestjs-config

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

标签 统计

node.js ×2

docker ×1

dockerfile ×1

mysql ×1

nestjs ×1

nestjs-config ×1

orm ×1

typeorm ×1