Skip to content

Commit

Permalink
basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Jun 7, 2013
1 parent fa557bb commit 6cd1767
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/employees.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var mongoose = require('mongoose');
var express = require('express');
var crudify = require('../');

// Create the db connection
var db = mongoose.createConnection('mongodb://localhost/business');

// Create our schema
var EmployeeSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
status: {
type: String,
enum: ['online','away','offline'],
default: 'offline'
}
});

// Add the model into db
var Employee = db.model('Employee', EmployeeSchema);

// Create the HTTP server
var app = express();
app.use(express.bodyParser());

// Expose our models from the database and add it to the HTTP server
var api = crudify(db);
api.expose('Employee');
api.hook(app);

// Listen to port 8080
app.listen(8080);

console.log("Server listening on 8080");

0 comments on commit 6cd1767

Please sign in to comment.