Skip to content

Instantly share code, notes, and snippets.

@svperfecta
Created October 20, 2011 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svperfecta/1300185 to your computer and use it in GitHub Desktop.
Save svperfecta/1300185 to your computer and use it in GitHub Desktop.
Up and running with Zappa, Mongoose and CoffeeScript
require('zappa') ->
# MongoDB Setup
mongoose = require 'mongoose'
db = mongoose.connect('mongodb://localhost/my_database')
# Declare schema for model
Schema = mongoose.Schema
User = new Schema
name: String
# Use the schema, create an object
User = mongoose.model 'User', User
@get '/': ->
user = new User
user.name = "Ted"
user.save
title = "Testing 123"
#Render the view
@render index: {user, title}
@view 'index': ->
h1 @title or 'View template'
p @user.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment