Shadowblade911 / MrLancer-v2

ISC License
0 stars 0 forks source link

addBook allows adding of books with duplicate titles and types #8

Closed jcotton42 closed 2 years ago

jcotton42 commented 2 years ago

addBook does not prevent adding duplicate books. As an example here I called /addbook Book2 book twice image

Note that a corresponding /deletebook Book2 book does remove both from the database. image

jcotton42 commented 2 years ago

Postgres supports multi-column uniqueness constraints that should address this quite nicely https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS and knex can set that up https://knexjs.org/#Schema-table-unique