(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
var key = <my key>, | |
secret = <my secret>, | |
https = require("https"), | |
https_options = { | |
"host": <host>, | |
"path": <path>, | |
"port": <port>, | |
"method": <method>, | |
"headers": { | |
"Authorization": "Basic " + new Buffer(key + ":" + secret, "utf8").toString("base64") |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Picking the right architecture = Picking the right battles + Managing trade-offs
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.
Number,Pokemon,Type 1,Type 2,HP,Attack,Defense,Speed,Special,GIF,PNG,Description | |
1,Bulbasaur,Grass,Poison,45,49,49,45,65,https://play.pokemonshowdown.com/sprites/bwani/bulbasaur.gif,https://play.pokemonshowdown.com/sprites/bw/bulbasaur.png,A strange seed was planted on its back at birth. The plant sprouts and grows with this Pokemon. | |
2,Ivysaur,Grass,Poison,60,62,63,60,80,https://play.pokemonshowdown.com/sprites/bwani/ivysaur.gif,https://play.pokemonshowdown.com/sprites/bw/ivysaur.png,"Often seen swimming elegantly by lake shores. It is often mistaken for the Japanese monster, Kappa." | |
3,Venusaur,Grass,Poison,80,82,83,80,100,https://play.pokemonshowdown.com/sprites/bwani/venusaur.gif,https://play.pokemonshowdown.com/sprites/bw/venusaur.png,"Because it stores several kinds of toxic gases in its body, it is prone to exploding without warning." | |
4,Charmander,Fire,,39,52,43,65,50,https://play.pokemonshowdown.com/sprites/bwani/charmander.gif,https://play.pokemonshowdown.com/sprites/bw/charmander.png,"Obviously prefer |