On OS X any of the databases can be installed with brew install [database]
Docker users can opt to use a database container to develop with as well. By default, a new Amber application generates a docker-compose.yml that can be used for this purpose.
2. Generate a new Amber application
With all dependencies successfully installed, we can generate a new application with amber new
After the code for the new application is generated, we will cd into the new directory and execute a shards install.
The shards install command may take a little while - it has to download all shard dependencies.
The default setup will use a postgresql database, use -d mysql or -d sqlite for mysql and sqlite, respectively.
amber new pet-tracker
3. Generate a resource
With the skeleton application generated, we can generate our first RESTful resource.
The amber generate scaffold command will help us do this.
g is shorthand for generate
amber g scaffold Pet name:string breed:string age:integer
4. Create and migrate the database
Generating the application and the scaffolded resource provides the configuration and migration files needed to set up the database.
amber db will help us do this, as you will see you can chain the db commands together.
amber db create migrate
This will create a new database and run the migration to create a pets table with the specified columns.
5. Build the application and run the server
We can use amber watch to both build the binary application and start the server. Additionally, amber watch will detect code changes then recompile and restart the application automatically.
The watch commands will keep observing for file changes within the project and recompiling the application.
6. Use your brand new web application!
Open any browser and goto http://localhost:3000 You should see a home page load and “Pets” in the nav bar. If you click on the “Pets” link, you should be able to perform all seven RESTful actions for the “pets” resource.