Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
iso2 | alias | |
---|---|---|
BM | Islands of Bermuda | |
BM | The Islands of Bermuda | |
BM | Bermudas | |
BM | The Bermudas | |
BM | Somers Isles | |
BM | The Somers Isles | |
BS | Bahama | |
BS | Bahamas | |
BS | The Bahamas |
Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
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.
// Component.js | |
const Component = props => ( | |
<MyContext.Consumer> | |
{(context) => ( | |
<Foo | |
bar={props.bar} | |
baz={context.baz} | |
/> | |
)} | |
</MyContext.Consumer> |
// sets globals: | |
// __stack, | |
// __line, | |
// __file, | |
// __function, | |
// __ext, | |
// __base | |
// we already have these: | |
// __filename which gives as an example: /Users/mjr/example.js |
import React from 'react'; | |
class CalendlyEmbed extends React.Component { | |
calendlyScriptSrc = 'https://assets.calendly.com/assets/external/widget.js' | |
buildCalendlyUrl = (account, eventName) => | |
`https://calendly.com/${account}/${eventName}` | |
componentDidMount() { | |
const head = document.querySelector('head') | |
const script = document.createElement('script') |
#!/bin/bash | |
#============================================================================== | |
#TITLE: mysql_backup.sh | |
#DESCRIPTION: script for automating the daily mysql backups on development computer | |
#AUTHOR: tleish | |
#DATE: 2013-12-20 | |
#VERSION: 0.4 | |
#USAGE: ./mysql_backup.sh | |
#CRON: | |
# example cron for daily db backup @ 9:15 am |
. | |
βββ actions | |
βββ stores | |
βββ views | |
βΒ Β βββ Anonymous | |
βΒ Β βΒ Β βββ __tests__ | |
βΒ Β βΒ Β βββ views | |
βΒ Β βΒ Β βΒ Β βββ Home | |
βΒ Β βΒ Β βΒ Β βΒ Β βββ __tests__ | |
βΒ Β βΒ Β βΒ Β βΒ Β βββ Handler.js |
var books = [ | |
'Genesis', | |
'Exodus', | |
'Leviticus', | |
'Numbers', | |
'Deuteronomy', | |
'Joshua', | |
'Judges', | |
'Ruth', | |
'1 Samuel', |