1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 4bb8cae81e
commit 6ab45fe935
13249 changed files with 317868 additions and 2101398 deletions

View File

@@ -1,18 +1,17 @@
var express = require('express')
var mongoose = require('../../../lib')
var express = require('express');
var mongoose = require('../../../lib');
var uri = 'mongodb://localhost/mongoose-shared-connection';
global.db = mongoose.createConnection(uri);
var routes = require('./routes')
var routes = require('./routes');
var app = express();
app.get('/', routes.home);
app.get('/insert', routes.insert);
app.get('/name', routes.modelName);
app.listen(8000, function () {
app.listen(8000, function() {
console.log('listening on http://localhost:8000');
})
});

View File

@@ -1,6 +1,5 @@
var Schema = require('../../../lib').Schema;
var mySchema = Schema({ name: String });
// db is global
/* global db */
module.exports = db.model('MyModel', mySchema);

View File

@@ -1,20 +1,20 @@
var model = require('./modelA')
var model = require('./modelA');
exports.home = function (req, res, next) {
model.find(function (err, docs) {
exports.home = function(req, res, next) {
model.find(function(err, docs) {
if (err) return next(err);
res.send(docs);
})
}
});
};
exports.modelName = function (req, res) {
exports.modelName = function(req, res) {
res.send('my model name is ' + model.modelName);
}
};
exports.insert = function (req, res, next) {
model.create({ name: 'inserting ' + Date.now() }, function (err, doc) {
exports.insert = function(req, res, next) {
model.create({ name: 'inserting ' + Date.now() }, function(err, doc) {
if (err) return next(err);
res.send(doc);
})
}
});
};