Skip to content

Instantly share code, notes, and snippets.

@jwo

jwo/game.js

Created Jul 6, 2017
Embed
What would you like to do?
sample schema for mongoose
const mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
mongoose.connect('mongodb://localhost:27017/eighties');
const gameSchema = new mongoose.Schema({
name: {type: String, required: true},
imageUrl: {type: String, required: true},
tags: [String],
year: {type: Number, required: true},
link: {type: String, required: true}
})
const Game = mongoose.model('Game', gameSchema);
const game = new Game()
game.name = "Contra"
game.imageUrl = "The imageUrl"
game.year = 1985
game.link = "The link"
game.save()
.then( function(game){
console.log("Check mongo!")
})
.catch( function(validationError){
console.log("Sorry sucker!")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment