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
let arrayWithNulls = [ | |
{image}, {logo}, {name}, {takingOrders}, {available}, {location}, | |
]; |
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 updateFoodTruck({ foodTruckId, image, logo, name, takingOrders, available, location }, currentUser) { | |
return new Promise((resolve, reject) => { | |
console.log(image); // => null | |
console.log(takingOrders); // => null | |
}); | |
} |
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
FoodTrucks.updateFoodTruck({ name: 'Updated FoodTruck Name', foodTruckId: '1234' }); |
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
// This is Good | |
function updateFoodTruck({ foodTruckId, image, logo, name, takingOrders, available, location }, currentUser) { | |
return new Promise((resolve, reject) => { | |
// Code Here | |
}); | |
} |
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
// 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 :( | |
}); | |
} |
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
// ... | |
FoodTruckSchema.statics.updateFoodTruck = updateFoodTruck; | |
function updateFoodTruck(input, currentUser) { | |
return new Promise((resolve, reject) => { | |
// Code Here | |
}); | |
} |
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
import mongoose, { Schema } from 'mongoose'; | |
export const FoodTruckSchema = new Schema({ | |
image: { | |
type: String, | |
}, | |
logo: { | |
type: String, | |
}, | |
name: { | |
type: String, |
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
`# 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 |
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
`# 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 ;) |
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
// 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> | |
) |