This repository exists to reproduce a bug found in sequelize auto model generation where a one to one relationship has a one to many relationship
foos.hasOne(bars, { as: "bar", foreignKey: "foo_id"});
foos.hasMany(bars, { as: "bars", foreignKey: "foo_id"});
-
Run
docker-compose up --build -d
-
Connect to database
psql "hostaddr=127.0.0.1 \
port=5555 \
user=postgres \
password=SomePassword \
dbname=postgres"
- Inspect the schema
\d foos
\d bars
- Install node dependencies:
npm i
- Generate models:
npm start
- Confirm
models/init-models.js
models the relationship as a one to many (foo -> bars).