Publish to my blog (weekly)

    • To check what sql queries schema:sync is going to run use:
    • typeorm schema:log
    • What is a Subscriber
    • All operations MUST be executed using the provided transactional entity manager.
    • the typescript files need to be compiled before running the commands.
    • ypeORM is able to automatically generate migration files with schema changes you made.
    • Alternatively you can also output your migrations as Javascript files using the o (alias for --outputJs) flag
    • typeorm migration:generate -n PostRefactoring
    • The migration:run and migration:revert commands only work on .js files.
    • To apply multi-line formatting to your generated migration queries, use the p (alias for --pretty) flag.
    • ts-node $(yarn bin typeorm) migration:run
    • ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run
    • await connection.manager.save(photo1);
    • await connection.manager.save(photo2);
    • await connection.manager.save(user);
    • @ManyToOne(() => User, user => user.photos)
    • user.photos = [photo1, photo2];
      12
      await connection.manager.save(user);
    • photo1.user = user;
      8
      await connection.manager.save(photo1);
    • .leftJoinAndSelect("user.photos", "photo")
    • photo2.user = user;
      13
      await connection.manager.save(photo2);
    • Where you set @ManyToOne - its related entity will have "relation id" and foreign key.
    • leftJoinAndSelect("photo.user", "user")
    • don't have to specify relations in the find command as it will ALWAYS be loaded automatically
    • eager loading enabled on a relation
    • use QueryBuilder eager relations are disabled, you have to use leftJoinAndSelect to load the relation.
    • userId | int(11) | FOREIGN KEY
    • A question can have multiple categories, and each category can have multiple questions.
    • Bi-directional relations allow you to join relations from both sides using QueryBuilder:
    • @JoinTable() is required for @ManyToMany relations. You must put @JoinTable on one (owning) side of relation.
    • post.postToCategories
    • @JoinTable must be only on one side of the relation.
    • eager loading enabled on a relation
    • we did not call save or softRemove for category1 and category2, but they will be automatically saved and soft-deleted when the cascade of relation options is set to true like this:
    • you use QueryBuilder eager relations are disabled,
    • ALWAYS be loaded automatically.
    • category.postToCategories
    • @ManyToOne(()
    • leftJoinAndSelect to load the relation.
    • await connection.manager.softRemove(newQuestion);
    • @ManyToOne(()
    • cascade: true
    • public post!: Post;
    • question_categories_category
    • public category!: Category;
    • public postToCategories!: PostToCategory[];
    • @OneToMany(()
    • @OneToMany(()
    • public postToCategories!: PostToCategory[];
    • @JoinTable()
    • Single Table Inheritance
    • When you'll load data from the database, you will have your object/array/primitive back via JSON.parse
    • Promise<Question[]>;
    • Eager relations only work when you use find* methods. If you use QueryBuilder eager relations are disabled and have to use leftJoinAndSelect to load the relation. Eager relations can only be used on one side of the relationship, using eager: true on both sides of relationship is disallowed.
    • await question.categories;
    • question.categories = Promise.resolve([category1, category2]);
    • n JavaScript and Node.JS you have to use promises if you want to have lazy-loaded relations. This is non-standard technique and considered experimental in TypeORM.
    • Promise<Category[]>;
    • 여러 변수에 대한 함수의 편미분이라는 것은 여러 변수들 중 하나에 대해서 미분하고, 나머지는 상수로 취급하는 것을 의미한다.
    • 미분 기하학
    • 벡터 계산
    • z = f(x, y, ...)에 대해서, z를 x에 대해서 편미분
    • 편미분은 일반적으로 본래의 함수에서와 같은 인수를 가지므로
    • y에 대한 미분의 경우에는 반대로 x를 상수치급해서 y에 대해서만 미분을 계산

Posted from Diigo. The rest of my favorite links are here.

댓글

이 블로그의 인기 게시물

Publish to my blog (weekly)

Publish to my blog (weekly)