- Go Web Basics
- HTTP Server
- Routing
- MYSQL
- Templates
- Assets
- Forms
- Middlewares
- Sessions
- JSON
- Websockets
- Hashing
41 - MongoAPI
- create mod init
- Install mux & mongo-go driver
- create atlas cluster (m0) & take conn url
42 - Models
- create folders inside package (same level as main.go)
- import bson/primitive from mongo-go
- create Netflix model (id, movie: str, watched: bool)
43 - DB Conn
- create controller to connect
- make pointer to controller
- Do inside init:
- define a "context" [look into context docs] as TODO
- create connection
- connect the collection pointer to the connection
Helpers:
Do crud in Context.background btw!
44 - Insert
- Insert movie
- return back created mongoDB ID
45 - Update
- take id param
- filter with id & set watched true
- collection updateOne
46 - Delete one and many
- take id(s)
- take filter & remove
- collection deleteOne / deleteMany
47 - Get all Movies
- use cursor instead of collection method
Controllers
48 - Get all Movies
- make req, res & call helper
- json encode end
49 - Mark Movie Watched
- Create controller for create movie and update as watched
50 - Delete
- Delete controller connect
51 - Routes & Testing APIs
- create router folder
- connect with all controllers
- export the router (Capitalize) as mux.Router pointer
- for import, just make folder name (ex: folder is router, then do [router.export-item] )
- test all APIs