02 Nov 2022 · 5 min read
Kecil, part 2 - database creation
Two dependencies to start:
npm i mysql dotenvmysql talks to the server, dotenv keeps credentials out of the source. Installing anything creates node_modules, which is the cue to add a .gitignore before the first commit:
node_modules/The schema
- user(#id, first_name, last_name, email, created_at, last_seen)
- pw(#user_id, hashed_password)
- link(#id, owner_id, source_id, target_url, created_at)
The password lives in its own table on purpose. Every ordinary read of a user - the dashboard, the settings page, the session lookup - then physically cannot pull the hash along with it. You only touch pw on login, register and password change.
The queries live behind a small db.js wrapper so nothing in the app writes raw SQL inline. That wrapper is what part 3 is about.

