Last active
December 12, 2015 09:49
-
-
Save runcom/4754417 to your computer and use it in GitHub Desktop.
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
/** | |
* Created by Antonio Murdaca. | |
* Date: 10/02/13 | |
* Time: 22.00 | |
*/ | |
var mongoose = require('mongoose') | |
,Schema = mongoose.Schema; | |
var postSchema = new Schema({ | |
title: String, | |
author: String, | |
date: {type: Date, default: Date.now}, | |
modified: Date, | |
body: String, | |
tags: [String], | |
comments: [{ | |
author: String, | |
body: String, | |
date: Date | |
}] | |
}); | |
var Post = mongoose.model('Post', postSchema); | |
exports.list = function(req, res) { | |
new Post({title: 'titlessssss', author: 'mhe babyyyyyyyyyyyy'}).save(); | |
console.log('yahi'); | |
} | |
exports.lista = function(req, res) { | |
Post.find(function(err, posts) { | |
//console.log(posts); | |
res.send(posts); | |
}); | |
} |
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
/** | |
* Created by Antonio Murdaca. | |
* Date: 10/02/13 | |
* Time: 10.20 | |
*/ | |
var index = require('./controllers/index'); | |
var user = require('./controllers/user'); | |
module.exports = function(app) { | |
app.get('/', index.index); | |
//app.get('/:id/', index.indexid); | |
app.get('/users', user.lista); | |
app.get('/users/edit', user.edit); | |
}; |
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
/* | |
* GET users listing. | |
*/ | |
var post = require('../models/post'); | |
exports.lista = function(req, res){ | |
post.list(); //TODO: should i pass req to post.list(req) or not?! | |
res.send('ciau'); | |
}; | |
exports.edit = function(req, res){ | |
post.lista(req, res); | |
//console.log(p); | |
//res.send(p); | |
//res.json(post.lista()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment