Create an Express based REST API for a Widget Store. Each widget has a single brand. A brand can have multiple widgets.
The following are the attributes for the widget
- name {string}, max length 256 characters
- quantity {integer}, number of widgets available
- brandId {uuid}, foreign key for brand
The following are the attributes for the brand
- name {string}, max length 256 characters
- lastSoldAt {date}, date when the widget was last sold, should update if widget quantity decreases
The REST API should support the following capabilities:
- Create a widget
- List all widgets
- Get a widget
- Update a widget including incrementing the quantity of a widget
- Delete a brand (which should delete all associated widgets)
Initializes the Widget and Brand tables
npx sequelize-cli db:migrate
Run this command to add some test data to the tables
npx sequelize db:seed:all
Removes all data from the tables
npx sequelize db:seed:undo
https://github.com/mapbox/node-sqlite3/wiki
sequelize-cli
We've provided precompiled 32 binaries for Linux, macos, and windows if you want to use the sqlite3 command line interface to view data in the database.
The following commands assume they are being run from the project's root folder.
.\cli\win32\sqlite3.exe .\db\inventory.sqlite
./cli/macos/sqlite3 ./db/inventory.sqlite
./cli/linux-x86/sqlite3 ./db/inventory.sqlite
Note that you will need support for 32 bit binaries on Linux which requires installing the following library:
ctrl-d will exit the cli tool
sudo yum install glibc.i686
sudo apt-get install ia32-libs