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
// Simple example where you have a many-many relationship with Categories and Posts | |
// in sequelizejs and want to send the associated data as part of the response | |
Category.findAll({include: ['posts'] }) | |
.success(function(categories) { | |
var results = categories.map(function(category) { | |
var temp = mapAttributes(category); | |
var p_results = category.posts.map(function(post){ |
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
customSchema(function () { | |
var mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/test'); | |
var Schema = mongoose.Schema, ObjectId = Schema.ObjectId; | |
//----------------------------- | |
var UserSchema = new Schema({ | |
email: { type: String, required: true }, |
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
$ rw routes | |
users GET /users.:format? users#index | |
users POST /users.:format? users#create | |
new_user GET /users/new.:format? users#new | |
edit_user GET /users/:id/edit.:format? users#edit | |
user DELETE /users/:id.:format? users#destroy | |
user PUT /users/:id.:format? users#update | |
user GET /users/:id.:format? users#show | |
login GET /login users#login |