Build a better mousetrap
$ cd ~/workspace/loopback-zero-to-hero/
If we inspect
server/datasources.json
out-of-the-box (OOTB), we should see that a memory database is in use as a mock placeholder of sorts. This is done so we may develop our application logic without worrying about the backend too early.cat ~/workspace/loopback-zero-to-hero/server/datasources.json { "db": { "name": "db", "connector": "memory" } }
Let's build a better mousetrap! Errrrr... database, Let's build a better database.
|||topic
Database Connectors
Read official docs on Database Connectors |||
Using a file to back the memory DB has significant advantages.
We can look at what's going on behind the scenes by simply peeking into a json file
We don't lose all our data on every restart.
So let's edit
server/datasources.json
by adding a line"file": "db.json"
to it:{ "db": { "name": "db", "connector": "memory", "file": "db.json" } }
Fire up the server:
node .
Project > Box Info
Open a browser window:
http://<box-name>.codio.io:3000/explorer/
The
Users
api will be ready to explore OOTB.Use
/POST Users
from the explorer UI to create a user:{ "username": "test", "password": "test", "email": "test@test.com" }
Use that as the json body and then click the
Try it out!
button.
Last updated