Updated mongoose

This commit is contained in:
Dobie Wollert
2015-11-24 22:08:58 -08:00
parent 71a05fb732
commit 8b5827c970
618 changed files with 122299 additions and 37754 deletions

1
node_modules/mongoose/examples/express/README.md generated vendored Normal file
View File

@ -0,0 +1 @@
Mongoose + Express examples

View File

@ -0,0 +1,6 @@
To run:
- Execute `npm install` from this directory
- Execute `node app.js`
- Navigate to `localhost:8000`

View File

@ -0,0 +1,17 @@
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 app = express();
app.get('/', routes.home);
app.get('/insert', routes.insert);
app.get('/name', routes.modelName);
app.listen(8000, function() {
console.log('listening on http://localhost:8000');
});

View File

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

View File

@ -0,0 +1,14 @@
{
"name": "connection-sharing",
"private": "true",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": { "express": "3.1.1" },
"repository": "",
"author": "",
"license": "BSD"
}

View File

@ -0,0 +1,20 @@
var model = require('./modelA');
exports.home = function(req, res, next) {
model.find(function(err, docs) {
if (err) return next(err);
res.send(docs);
});
};
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) {
if (err) return next(err);
res.send(doc);
});
};