Skip to content

TS: typeorm basics #32

@fatemeh-ra

Description

@fatemeh-ra

Description

In this issue we want to create a simple database using typeorm. Install typeorm and sqlite, and create a dataSource.ts file with sqlite type in your project. Define a simple entity for User:

User {
  id: number,
  fName: string,
  lName: string,
  age: number
}

id should be an autogenerating column for your entity.
Add the entity to your data-source.ts and initialize and migrate the database in index.ts. Check the created database by saving one user information.

What to google

  • typeorm
  • dataSource
  • database entity
  • database initialization and migration
  • save query

Suggested resources

https://typeorm.io/
https://orkhan.gitbook.io/typeorm/docs/data-source
https://medium.com/@peturgeorgievv/how-to-setup-automatic-migrations-with-typeorm-on-deployment-2224544a4838

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions