Skip to content

Instantly share code, notes, and snippets.

View donedgardo's full-sized avatar

Edgardo Carreras donedgardo

View GitHub Profile
@donedgardo
donedgardo / es_9.js
Created February 8, 2017 19:52
ES6 Article
let arrayWithNulls = [
{image}, {logo}, {name}, {takingOrders}, {available}, {location},
];
@donedgardo
donedgardo / es_8.js
Created February 8, 2017 19:50
ES6 Article
function updateFoodTruck({ foodTruckId, image, logo, name, takingOrders, available, location }, currentUser) {
return new Promise((resolve, reject) => {
console.log(image); // => null
console.log(takingOrders); // => null
});
}
@donedgardo
donedgardo / es6_7.js
Created February 8, 2017 19:48
ES6 Article
FoodTrucks.updateFoodTruck({ name: 'Updated FoodTruck Name', foodTruckId: '1234' });
@donedgardo
donedgardo / es6_6.js
Created February 8, 2017 19:47
ES6 Article
// This is Good
function updateFoodTruck({ foodTruckId, image, logo, name, takingOrders, available, location }, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
});
}
@donedgardo
donedgardo / es6_5.js
Created February 8, 2017 19:46
ES6 Article
// This is bad
function updateFoodTruck(input, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
let foodTruckId = input.foodTruckId;
let image = input.image;
... and so on :(
});
}
@donedgardo
donedgardo / es6_4.js
Created February 8, 2017 19:46
ES6 Article
// ...
FoodTruckSchema.statics.updateFoodTruck = updateFoodTruck;
function updateFoodTruck(input, currentUser) {
return new Promise((resolve, reject) => {
// Code Here
});
}
@donedgardo
donedgardo / es6_3.js
Created February 8, 2017 19:45
ES6 Article
import mongoose, { Schema } from 'mongoose';
export const FoodTruckSchema = new Schema({
image: {
type: String,
},
logo: {
type: String,
},
name: {
type: String,
@donedgardo
donedgardo / es6_2.js
Created February 8, 2017 19:43
ES 6 article
`# Our Schema allows these mutations
type Mutation {
# Update Food Truck (omg only in one mutation?!) :p
updateFoodTruck(input: FoodTruckUpdateInput!): FoodTruck
}
# Defines the type of the input
input FoodTruckUpdateInput {
# Id of foodtruck to update
foodTruckId: ID!
# Photo of FoodTruck
@donedgardo
donedgardo / es6.js
Last active February 8, 2017 19:43
ES 6 Article
`# Our Schema allows these mutations
type Mutation {
# Update Food Truck Image
updateFoodTruckImage(foodTruckId: ID!, image:String ): FoodTruck
# Update Food Truck Logo
updateFoodTruckLogo(foodTruckId: ID!, logo:String ): FoodTruck
# Update Food Truck Name
updateFoodTruckName(foodTruckId: ID!, name:String ): FoodTruck
...
... and so on with each field! (I'm too lazy to keep doing this ;)
@donedgardo
donedgardo / Next_vs_Meteor2.js
Created February 8, 2017 19:33
Next vs Meteor Article
// pages/index.js
import Link from 'next/link'
export default () => (
<div>Click <Link href="/about"><a>here</a></Link> to read more</div>
)
// pages/about.js
export default () => (
<p>Welcome to About!</p>
)