This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM(cats.net_worth) | |
FROM owners | |
INNER JOIN cats_owners | |
ON owners.id = cats_owners.owner_id | |
JOIN cats ON cats_owners.cat_id = cats.id | |
WHERE cats_owners.owner_id = 2; | |
# which will return the following | |
SUM(cats.net_worth) | |
------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TABLE: cats | |
id name age breed net_worth | |
---------- ---------- ---------- ------------- ---------- | |
1 Maru 3 Scottish Fold 1000000 | |
2 Hana 1 Tabby 21800 | |
3 Grumpy Cat 4 Persian 181600 | |
4 Lil\' Bub 2 Tortoiseshell 2000000 | |
=============================================================== | |
|| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM owners | |
INNER JOIN cats_owners | |
ON owners.id = cats_owners.owner_id; | |
# which would return: | |
id name cat_id owner_id | |
---------- ---------- ---------- ---------- | |
2 Sophie 3 2 | |
3 Penny 3 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT cats.name AS cat, owners.name AS owner |P | SELECT * | |
FROM owners |R | FROM owners | |
INNER JOIN cats_owners |E | INNER JOIN cats_owners | |
ON owners.id = cats_owners.owner_id |V | ON owners.id = cats_owners.owner_id; | |
INNER JOIN cats |I | | |
ON cats_owners.cat_id = cats.id; |O | # which returned: | |
|U | | |
# returns this: |S ->| id name cat_id owner_id | |
| | ---------- ---------- ---------- ---------- | |
cat owner |L | 2 Sophie 3 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM owners | |
INNER JOIN cats_owners | |
ON owners.id = cats_owners.owner_id | |
INNER JOIN cats | |
ON cats_owners.cat_id = cats.id; | |
# returns | |
id name cat_id owner_id id name age breed net_worth | |
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Show | |
attr_accessor :stand_up, :club | |
@@all = [] | |
def initialize(stand_up, club) | |
@stand_up = stand_up | |
@club = club | |
@@all << self | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StandUp |class Club | |
| | |
attr_accessor :name | attr_accessor :club_name | |
| | |
@@all = [] | @@all = [] | |
| | |
def initialize(name) | def initialize(club_name) | |
@name = name | @club_name = club_name | |
@@all << self | @@all << self | |
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BelongsToClass | |
# accessors and whatnot | |
@@all = [] | |
def initialize(has_many_class_a_obj, has_many_class_b_obj) | |
@has_many_class_a_obj = has_many_class_a_obj | |
@has_many_class_b_obj = has_many_class_b_obj | |
end | |
def self.all | |
@@all | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// we'll use arrow functions for brevity | |
let asynchProm = new Promise((resolve, reject) => { | |
let fakeCode = 200; | |
window.setTimeout(() => { | |
if (fakeCode === 200) { | |
resolve({status: "OK"}) | |
} else { | |
reject({status: "ERROR"}) | |
} | |
}, 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function grabber(resource, fakeStatus) { | |
return new Promise((resolve, reject) => { | |
window.setTimeout(() => { | |
if (fakeStatus === 200) { | |
resolve(`load ${resource}`) | |
} else { | |
reject("Error") | |
} | |
}, 3000); | |
}); |
OlderNewer