This is a project designed to get you to write your own simple ORM.
-
Fork/clone
-
npm install
-
createdb oop_orm_dev && createdb oop_orm_test
-
npm run migrate
-
npm run seed
-
npm run test
For this exercise you will only be creating the Model for a Theatre. Theatres have a name
and address
field outside of all the usual stuff. You will be writing your model so that it has the following static and instance methods.
GET ALL
const theatres = await Theatre.all()
// [ { ... }, { ... }, { ... } ]
GET ONE
const theatres = await Theatre.find(1)
// { ... }
CREATE
const theatre = new Theatre({ name: 'My Theatre', address: '123 Main Street' })
await theatre.save()
// { id: xx, name: 'My Theatre', address: '123 Main Street' }
UPDATE
const theatre = await Theatre.find(1)
theatre.name = 'My New Name'
await theatre.save()
// { id: 1, name: 'My New Name', ... }
DESTROY
const theatre = await Theatre.find(1)
await theatre.destroy()
// { id: 1, ... }