This is a bare minimum sample app using Joist as an ORM.
There are two domain objects, Author
and Book
, and a single test, Author.test.ts
.
There are no examples of business logic or Joist's various features; for those see the docs.
yarn
yarn db
yarn test
A typical workflow for adding a new entity looks like:
- Run
yarn pg-new-migration "add publisher"
- Edit the
migrations/...add-publisher.ts
file and addcreateEntityTable(pgm, "publishers", { name: { type: "text", notNull: true }, });
- Run
yarn joist-migrate
- If you change your migration, and want to re-apply it from scratch, run
docker-compose exec db ./reset.sh
- If you change your migration, and want to re-apply it from scratch, run
- Run
yarn joist-codegen
- Copy/paste the
Author.test.ts
and write a test forPublisher
TODO: Automate this with more, probably with mrm.
-
Install basic prettier/TypeScript/jest.
npm install -g mrm npm install -g \ @homebound/mrm-tasks-prettier \ @homebound/mrm-tasks-gitignore \ @homebound/mrm-tasks-typescript mrm @homebound/mrm-tasks-prettier \ @homebound/mrm-tasks-gitignore \ @homebound/mrm-tasks-typescript
-
Copy/paste
migrations/...author.ts
-
Add
joist-orm
,joist-migration-utils
,joist-codegen
topackage.json
-
Copy/paste
run.sh
-
Copy/paste
env/local.env
, changed port -
Add
ts-node
topackage.json
- Should come from
mrm
?
- Should come from
-
Add
joist-migrate
script, run it -
Add
joist-codegen
script, run it -
Add
Author.test.ts
-
Add
env-cmd
topackage.json
-
Add
pg-migration
topackage.json
-
Add
.gitattributes
to suppress diffs on generated files