Skip to content

Instantly share code, notes, and snippets.

@runcom
Last active December 12, 2015 09:49
Show Gist options
  • Save runcom/4754417 to your computer and use it in GitHub Desktop.
Save runcom/4754417 to your computer and use it in GitHub Desktop.
/**
* 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);
});
}
/**
* 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);
};
/*
* 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