Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo
# Using edge-git ensures we're always pulling the latest | |
# You can lock into a specific version using the *-git tags | |
# on https://hub.docker.com/_/docker/ | |
image: docker:edge-git | |
services: | |
- docker:dind | |
# If you only need compose in a specific step definitely put this | |
# only in that step so it's not executed unnecessarily | |
before_script: |
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.
########################################## | |
# To run: | |
# curl -sSL https://gist.githubusercontent.com/andrewelkins/1adc587feb610f586f8f40b50b7efc3a/install-docker-on-linux-mint-18.sh | bash -x | |
########################################## | |
# Kernel version http://stackoverflow.com/a/4024263 | |
versionlte() { | |
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] | |
} | |
versionlt() { |
# checkout, compile & install | |
git clone https://github.com/facebook/watchman.git | |
cd watchman/ | |
git checkout v4.9.0 | |
sudo apt-get install -y autoconf automake build-essential python-dev libssl-dev libtool | |
./autogen.sh | |
./configure | |
make | |
sudo make install |
postgres: | |
image: postgres:9.4 | |
volumes: | |
- ./init.sql:/docker-entrypoint-initdb.d/init.sql |
/* | |
* CHALLANGE: | |
* Cache `index.html` file using service worker. | |
* | |
* This bit of code is included in <script> tag of index.html | |
* if (navigator.serviceWorker) { | |
* navigator.serviceWorker.register('serviceworker.js', {scope: '/'}) | |
* } | |
* | |
*/ |