This file contains hidden or 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
| // bin/www | |
| models.sequelize.sync().then(function() { | |
| server.listen(port); | |
| server.on('error', onError); | |
| server.on('listening', onListening); | |
| }); |
This file contains hidden or 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
| // models/user.js | |
| module.exports = function(sequelize, DataTypes) { | |
| var User = sequelize.define('User', { | |
| username: DataTypes.STRING | |
| }, { | |
| classMethods: { | |
| associate: function(models) { | |
| User.hasMany(models.Listing); | |
| } |
This file contains hidden or 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
| // models/listing.js | |
| module.exports = function(sequelize, DataTypes) { | |
| var Listing = sequelize.define('Listing', { | |
| title: DataTypes.STRING, | |
| description: DataTypes.TEXT | |
| }, { | |
| classMethods: { | |
| associate: function(models) { | |
| Listing.belongsTo(models.User); |
This file contains hidden or 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
| . | |
| ├── config | |
| │ └── config.json | |
| ├── migrations | |
| │ ├── 20161104204911-create-user.js | |
| │ └── 20161104205207-create-listing.js | |
| ├── models | |
| │ ├── index.js | |
| │ ├── listing.js | |
| │ └── user.js |
This file contains hidden or 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
| $ node_modules/.bin/sequelize init | |
| $ node_modules/.bin/sequelize model:create --name User --attributes username:string | |
| $ node_modules/.bin/sequelize model:create --name Listing --attributes title:string,description:text |
This file contains hidden or 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
| { | |
| "dependencies": { | |
| "sequelize": "^3.24.7", | |
| "sequelize-cli": "^2.4.0" | |
| } | |
| } |
This file contains hidden or 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
| { | |
| "name": "my-app", | |
| "version": "0.0.0", | |
| "private": true, | |
| "scripts": { | |
| "start": "node ./bin/www" | |
| }, | |
| "dependencies": { | |
| "body-parser": "^1.15.2", | |
| "cookie-parser": "^1.4.3", |
This file contains hidden or 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
| . | |
| ├── app.js | |
| ├── bin | |
| │ └── www | |
| ├── package.json | |
| ├── public | |
| │ ├── images | |
| │ ├── javascripts | |
| │ └── stylesheets | |
| │ └── style.css |
This file contains hidden or 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
| def hello(name) | |
| puts "Welcome to learning how to code #{name}" | |
| end |
This file contains hidden or 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
| Challenge setup | |
| Specification: | |
| Thermostat starts at 20 degrees | |
| You can increase the temperature with the up button | |
| You can decrease the temperature with the down button | |
| The minimum temperature is 10 degrees | |
| If power saving mode is on, the maximum temperature is 25 degrees | |
| If power saving mode is off, the maximum temperature is 32 degrees |