diff options
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples')
44 files changed, 0 insertions, 2100 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md deleted file mode 100644 index cb32898..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md +++ /dev/null @@ -1,41 +0,0 @@ -This directory contains runnable sample mongoose programs. - -To run: - - - first install [Node.js](http://nodejs.org/) - - from the root of the project, execute `npm install -d` - - in the example directory, run `npm install -d` - - from the command line, execute: `node example.js`, replacing "example.js" with the name of a program. - - -Goal is to show: - -- ~~global schemas~~ -- ~~GeoJSON schemas / use (with crs)~~ -- text search (once MongoDB removes the "Experimental/beta" label) -- ~~lean queries~~ -- ~~statics~~ -- methods and statics on subdocs -- custom types -- ~~querybuilder~~ -- ~~promises~~ -- accessing driver collection, db -- ~~connecting to replica sets~~ -- connecting to sharded clusters -- enabling a fail fast mode -- on the fly schemas -- storing files -- ~~map reduce~~ -- ~~aggregation~~ -- advanced hooks -- using $elemMatch to return a subset of an array -- query casting -- upserts -- pagination -- express + mongoose session handling -- ~~group by (use aggregation)~~ -- authentication -- schema migration techniques -- converting documents to plain objects (show transforms) -- how to $unset - diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js deleted file mode 100644 index 793c8cb..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js +++ /dev/null @@ -1,103 +0,0 @@ - -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)), - gender: 'Male', - likes: ['movies', 'games', 'dogs'] - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)), - gender: 'Female', - likes: ['movies', 'birds', 'cats'] - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)), - gender: 'Male', - likes: ['tv', 'games', 'rabbits'] - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)), - gender: 'Female', - likes: ['books', 'cats', 'dogs'] - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)), - gender: 'Male', - likes: ['glasses', 'wine', 'the night'] - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) throw err; - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handle error - } - - // run an aggregate query that will get all of the people who like a given - // item. To see the full documentation on ways to use the aggregate - // framework, see http://docs.mongodb.org/manual/core/aggregation/ - Person.aggregate( - // select the fields we want to deal with - {$project: {name: 1, likes: 1}}, - // unwind 'likes', which will create a document for each like - {$unwind: '$likes'}, - // group everything by the like and then add each name with that like to - // the set for the like - {$group: { - _id: {likes: '$likes'}, - likers: {$addToSet: '$name'} - }}, - function(err, result) { - if (err) throw err; - console.log(result); - /* [ - { _id: { likes: 'the night' }, likers: [ 'alucard' ] }, - { _id: { likes: 'wine' }, likers: [ 'alucard' ] }, - { _id: { likes: 'books' }, likers: [ 'lilly' ] }, - { _id: { likes: 'glasses' }, likers: [ 'alucard' ] }, - { _id: { likes: 'birds' }, likers: [ 'mary' ] }, - { _id: { likes: 'rabbits' }, likers: [ 'bob' ] }, - { _id: { likes: 'cats' }, likers: [ 'lilly', 'mary' ] }, - { _id: { likes: 'dogs' }, likers: [ 'lilly', 'bill' ] }, - { _id: { likes: 'tv' }, likers: [ 'bob' ] }, - { _id: { likes: 'games' }, likers: [ 'bob', 'bill' ] }, - { _id: { likes: 'movies' }, likers: [ 'mary', 'bill' ] } - ] */ - - cleanup(); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json deleted file mode 100644 index 53ed2e1..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "aggregate-example", - "private": "true", - "version": "0.0.0", - "description": "deps for aggregate example", - "main": "aggregate.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js deleted file mode 100644 index 607bb07..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js +++ /dev/null @@ -1,17 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date, - gender: String, - likes: [String] - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js deleted file mode 100644 index 1f648b9..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js +++ /dev/null @@ -1,77 +0,0 @@ - -var mongoose = require('mongoose'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Schema - */ - -var CharacterSchema = Schema({ - name: { - type: String, - required: true - }, - health: { - type: Number, - min: 0, - max: 100 - } -}); - -/** - * Methods - */ - -CharacterSchema.methods.attack = function() { - console.log('%s is attacking', this.name); -}; - -/** - * Character model - */ - -var Character = mongoose.model('Character', CharacterSchema); - -/** - * Connect to the database on localhost with - * the default port (27017) - */ - -var dbname = 'mongoose-example-doc-methods-' + ((Math.random() * 10000) | 0); -var uri = 'mongodb://localhost/' + dbname; - -console.log('connecting to %s', uri); - -mongoose.connect(uri, function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - example(); -}); - -/** - * Use case - */ - -function example() { - Character.create({name: 'Link', health: 100}, function(err, link) { - if (err) return done(err); - console.log('found', link); - link.attack(); // 'Link is attacking' - done(); - }); -} - -/** - * Clean up - */ - -function done(err) { - if (err) console.error(err); - mongoose.connection.db.dropDatabase(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md deleted file mode 100644 index 7ba07b8..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md +++ /dev/null @@ -1 +0,0 @@ -Mongoose + Express examples diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md deleted file mode 100644 index fc709a3..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md +++ /dev/null @@ -1,6 +0,0 @@ - -To run: - -- Execute `npm install` from this directory -- Execute `node app.js` -- Navigate to `localhost:8000` diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js deleted file mode 100644 index 8fb2fee..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js +++ /dev/null @@ -1,17 +0,0 @@ - -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'); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js deleted file mode 100644 index 78f9ff6..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js +++ /dev/null @@ -1,5 +0,0 @@ -var Schema = require('../../../lib').Schema; -var mySchema = Schema({name: String}); - -/* global db */ -module.exports = db.model('MyModel', mySchema); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json deleted file mode 100644 index e326165..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "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" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js deleted file mode 100644 index 35e4f8f..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js +++ /dev/null @@ -1,20 +0,0 @@ - -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); - }); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js deleted file mode 100644 index f950dea..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js +++ /dev/null @@ -1,22 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - // NOTE : This object must conform *precisely* to the geoJSON specification - // you cannot embed a geoJSON doc inside a model or anything like that- IT - // MUST BE VANILLA - var LocationObject = new Schema({ - loc: { - type: {type: String}, - coordinates: [] - } - }); - // define the index - LocationObject.index({loc: '2dsphere'}); - - mongoose.model('Location', LocationObject); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js deleted file mode 100644 index 8e5dd2b..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js +++ /dev/null @@ -1,56 +0,0 @@ -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./geoJSONSchema.js')(); - -var Location = mongoose.model('Location'); - -// define some dummy data -// note: the type can be Point, LineString, or Polygon -var data = [ - {loc: {type: 'Point', coordinates: [-20.0, 5.0]}}, - {loc: {type: 'Point', coordinates: [6.0, 10.0]}}, - {loc: {type: 'Point', coordinates: [34.0, -50.0]}}, - {loc: {type: 'Point', coordinates: [-100.0, 70.0]}}, - {loc: {type: 'Point', coordinates: [38.0, 38.0]}} -]; - - -mongoose.connect('mongodb://localhost/locations', function(err) { - if (err) { - throw err; - } - - Location.on('index', function(err) { - if (err) { - throw err; - } - // create all of the dummy locations - async.each(data, function(item, cb) { - Location.create(item, cb); - }, function(err) { - if (err) { - throw err; - } - // create the location we want to search for - var coords = {type: 'Point', coordinates: [-5, 5]}; - // search for it - Location.find({loc: {$near: coords}}).limit(1).exec(function(err, res) { - if (err) { - throw err; - } - console.log('Closest to %s is %s', JSON.stringify(coords), res); - cleanup(); - }); - }); - }); -}); - -function cleanup() { - Location.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js deleted file mode 100644 index 3ff8c0b..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js +++ /dev/null @@ -1,100 +0,0 @@ -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)), - gender: 'Male', - likes: ['movies', 'games', 'dogs'], - loc: [0, 0] - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)), - gender: 'Female', - likes: ['movies', 'birds', 'cats'], - loc: [1, 1] - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)), - gender: 'Male', - likes: ['tv', 'games', 'rabbits'], - loc: [3, 3] - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)), - gender: 'Female', - likes: ['books', 'cats', 'dogs'], - loc: [6, 6] - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)), - gender: 'Male', - likes: ['glasses', 'wine', 'the night'], - loc: [10, 10] - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) { - throw err; - } - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handler error - } - - // let's find the closest person to bob - Person.find({name: 'bob'}, function(err, res) { - if (err) { - throw err; - } - - res[0].findClosest(function(err, closest) { - if (err) { - throw err; - } - - console.log('%s is closest to %s', res[0].name, closest); - - - // we can also just query straight off of the model. For more - // information about geospatial queries and indexes, see - // http://docs.mongodb.org/manual/applications/geospatial-indexes/ - var coords = [7, 7]; - Person.find({loc: {$nearSphere: coords}}).limit(1).exec(function(err, res) { - console.log('Closest to %s is %s', coords, res); - cleanup(); - }); - }); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json deleted file mode 100644 index 75c2a0e..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "geospatial-example", - "private": "true", - "version": "0.0.0", - "description": "deps for geospatial example", - "main": "geospatial.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js deleted file mode 100644 index e816637..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js +++ /dev/null @@ -1,27 +0,0 @@ -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date, - gender: String, - likes: [String], - // define the geospatial field - loc: {type: [Number], index: '2d'} - }); - - // define a method to find the closest person - PersonSchema.methods.findClosest = function(cb) { - return this.model('Person').find({ - loc: {$nearSphere: this.loc}, - name: {$ne: this.name} - }).limit(1).exec(cb); - }; - - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js deleted file mode 100644 index af9ff11..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js +++ /dev/null @@ -1,47 +0,0 @@ -var mongoose = require('../../lib'); - - -// import the global schema, this can be done in any file that needs the model -require('./person.js')(); - -// grab the person model object -var Person = mongoose.model('Person'); - -// connect to a server to do a quick write / read example - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) { - throw err; - } - - Person.create({ - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)) - }, function(err, bill) { - if (err) { - throw err; - } - console.log('People added to db: %s', bill.toString()); - Person.find({}, function(err, people) { - if (err) { - throw err; - } - - people.forEach(function(person) { - console.log('People in the db: %s', person.toString()); - }); - - // make sure to clean things up after we're done - setTimeout(function() { - cleanup(); - }, 2000); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js deleted file mode 100644 index 39ae725..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js +++ /dev/null @@ -1,14 +0,0 @@ -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js deleted file mode 100644 index 763367f..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js +++ /dev/null @@ -1,84 +0,0 @@ - -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)), - gender: 'Male', - likes: ['movies', 'games', 'dogs'] - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)), - gender: 'Female', - likes: ['movies', 'birds', 'cats'] - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)), - gender: 'Male', - likes: ['tv', 'games', 'rabbits'] - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)), - gender: 'Female', - likes: ['books', 'cats', 'dogs'] - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)), - gender: 'Male', - likes: ['glasses', 'wine', 'the night'] - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) throw err; - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handle error - } - - // lean queries return just plain javascript objects, not - // MongooseDocuments. This makes them good for high performance read - // situations - - // when using .lean() the default is true, but you can explicitly set the - // value by passing in a boolean value. IE. .lean(false) - var q = Person.find({age: {$lt: 1000}}).sort('age').limit(2).lean(); - q.exec(function(err, results) { - if (err) throw err; - console.log('Are the results MongooseDocuments?: %s', results[0] instanceof mongoose.Document); - - console.log(results); - cleanup(); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json deleted file mode 100644 index 6ee511d..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "lean-example", - "private": "true", - "version": "0.0.0", - "description": "deps for lean example", - "main": "lean.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js deleted file mode 100644 index b0bd2ed..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js +++ /dev/null @@ -1,16 +0,0 @@ -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date, - gender: String, - likes: [String] - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js deleted file mode 100644 index 6d67fbf..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js +++ /dev/null @@ -1,100 +0,0 @@ -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)), - gender: 'Male' - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)), - gender: 'Female' - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)), - gender: 'Male' - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)), - gender: 'Female' - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)), - gender: 'Male' - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) throw err; - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handle error - } - - // alright, simple map reduce example. We will find the total ages of each - // gender - - // create the options object - var o = {}; - - o.map = function() { - // in this function, 'this' refers to the current document being - // processed. Return the (gender, age) tuple using - /* global emit */ - emit(this.gender, this.age); - }; - - // the reduce function receives the array of ages that are grouped by the - // id, which in this case is the gender - o.reduce = function(id, ages) { - return Array.sum(ages); - }; - - // other options that can be specified - - // o.query = { age : { $lt : 1000 }}; // the query object - // o.limit = 3; // max number of documents - // o.keeptemp = true; // default is false, specifies whether to keep temp data - // o.finalize = someFunc; // function called after reduce - // o.scope = {}; // the scope variable exposed to map/reduce/finalize - // o.jsMode = true; // default is false, force execution to stay in JS - o.verbose = true; // default is false, provide stats on the job - // o.out = {}; // objects to specify where output goes, by default is - // returned, but can also be stored in a new collection - // see: http://mongoosejs.com/docs/api.html#model_Model.mapReduce - Person.mapReduce(o, function(err, results, stats) { - console.log('map reduce took %d ms', stats.processtime); - console.log(results); - cleanup(); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json deleted file mode 100644 index 4240068..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "map-reduce-example", - "private": "true", - "version": "0.0.0", - "description": "deps for map reduce example", - "main": "mapreduce.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js deleted file mode 100644 index 9e2f084..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js +++ /dev/null @@ -1,16 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date, - gender: String - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js deleted file mode 100644 index fe6de72..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js +++ /dev/null @@ -1,134 +0,0 @@ - -var assert = require('assert'); -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; -var ObjectId = mongoose.Types.ObjectId; - -/** - * Connect to the db - */ - -var dbname = 'testing_populateAdInfinitum_' + require('../../lib/utils').random(); -mongoose.connect('localhost', dbname); -mongoose.connection.on('error', function() { - console.error('connection error', arguments); -}); - -/** - * Schemas - */ - -var user = new Schema({ - name: String, - friends: [{ - type: Schema.ObjectId, - ref: 'User' - }] -}); -var User = mongoose.model('User', user); - -var blogpost = Schema({ - title: String, - tags: [String], - author: { - type: Schema.ObjectId, - ref: 'User' - } -}); -var BlogPost = mongoose.model('BlogPost', blogpost); - -/** - * example - */ - -mongoose.connection.on('open', function() { - /** - * Generate data - */ - - var userIds = [new ObjectId, new ObjectId, new ObjectId, new ObjectId]; - var users = []; - - users.push({ - _id: userIds[0], - name: 'mary', - friends: [userIds[1], userIds[2], userIds[3]] - }); - users.push({ - _id: userIds[1], - name: 'bob', - friends: [userIds[0], userIds[2], userIds[3]] - }); - users.push({ - _id: userIds[2], - name: 'joe', - friends: [userIds[0], userIds[1], userIds[3]] - }); - users.push({ - _id: userIds[3], - name: 'sally', - friends: [userIds[0], userIds[1], userIds[2]] - }); - - User.create(users, function(err) { - assert.ifError(err); - - var blogposts = []; - blogposts.push({ - title: 'blog 1', - tags: ['fun', 'cool'], - author: userIds[3] - }); - blogposts.push({ - title: 'blog 2', - tags: ['cool'], - author: userIds[1] - }); - blogposts.push({ - title: 'blog 3', - tags: ['fun', 'odd'], - author: userIds[2] - }); - - BlogPost.create(blogposts, function(err) { - assert.ifError(err); - - /** - * Population - */ - - BlogPost - .find({tags: 'fun'}) - .lean() - .populate('author') - .exec(function(err, docs) { - assert.ifError(err); - - /** - * Populate the populated documents - */ - - var opts = { - path: 'author.friends', - select: 'name', - options: {limit: 2} - }; - - BlogPost.populate(docs, opts, function(err, docs) { - assert.ifError(err); - console.log('populated'); - var s = require('util').inspect(docs, {depth: null, colors: true}); - console.log(s); - done(); - }); - }); - }); - }); -}); - -function done(err) { - if (err) console.error(err.stack); - mongoose.connection.db.dropDatabase(function() { - mongoose.connection.close(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js deleted file mode 100644 index 252cc53..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js +++ /dev/null @@ -1,103 +0,0 @@ - -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Console schema - */ - -var consoleSchema = Schema({ - name: String, - manufacturer: String, - released: Date -}); -var Console = mongoose.model('Console', consoleSchema); - -/** - * Game schema - */ - -var gameSchema = Schema({ - name: String, - developer: String, - released: Date, - consoles: [{ - type: Schema.Types.ObjectId, - ref: 'Console' - }] -}); -var Game = mongoose.model('Game', gameSchema); - -/** - * Connect to the console database on localhost with - * the default port (27017) - */ - -mongoose.connect('mongodb://localhost/console', function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - createData(); -}); - -/** - * Data generation - */ - -function createData() { - Console.create( - { - name: 'Nintendo 64', - manufacturer: 'Nintendo', - released: 'September 29, 1996' - }, - function(err, nintendo64) { - if (err) return done(err); - - Game.create({ - name: 'Legend of Zelda: Ocarina of Time', - developer: 'Nintendo', - released: new Date('November 21, 1998'), - consoles: [nintendo64] - }, - function(err) { - if (err) return done(err); - example(); - }); - } - ); -} - -/** - * Population - */ - -function example() { - Game - .findOne({name: /^Legend of Zelda/}) - .populate('consoles') - .exec(function(err, ocinara) { - if (err) return done(err); - - console.log( - '"%s" was released for the %s on %s', - ocinara.name, - ocinara.consoles[0].name, - ocinara.released.toLocaleDateString() - ); - - done(); - }); -} - -function done(err) { - if (err) console.error(err); - Console.remove(function() { - Game.remove(function() { - mongoose.disconnect(); - }); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js deleted file mode 100644 index c7eadfe..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js +++ /dev/null @@ -1,109 +0,0 @@ - -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Console schema - */ - -var consoleSchema = Schema({ - name: String, - manufacturer: String, - released: Date -}); -var Console = mongoose.model('Console', consoleSchema); - -/** - * Game schema - */ - -var gameSchema = Schema({ - name: String, - developer: String, - released: Date, - consoles: [{ - type: Schema.Types.ObjectId, - ref: 'Console' - }] -}); -var Game = mongoose.model('Game', gameSchema); - -/** - * Connect to the console database on localhost with - * the default port (27017) - */ - -mongoose.connect('mongodb://localhost/console', function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - createData(); -}); - -/** - * Data generation - */ - -function createData() { - Console.create( - { - name: 'Nintendo 64', - manufacturer: 'Nintendo', - released: 'September 29, 1996' - }, - function(err, nintendo64) { - if (err) return done(err); - - Game.create({ - name: 'Legend of Zelda: Ocarina of Time', - developer: 'Nintendo', - released: new Date('November 21, 1998'), - consoles: [nintendo64] - }, - function(err) { - if (err) return done(err); - example(); - }); - } - ); -} - -/** - * Population - */ - -function example() { - Game - .findOne({name: /^Legend of Zelda/}) - .exec(function(err, ocinara) { - if (err) return done(err); - - console.log('"%s" console _id: %s', ocinara.name, ocinara.consoles[0]); - - // population of existing document - ocinara.populate('consoles', function(err) { - if (err) return done(err); - - console.log( - '"%s" was released for the %s on %s', - ocinara.name, - ocinara.consoles[0].name, - ocinara.released.toLocaleDateString() - ); - - done(); - }); - }); -} - -function done(err) { - if (err) console.error(err); - Console.remove(function() { - Game.remove(function() { - mongoose.disconnect(); - }); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js deleted file mode 100644 index 61b4e85..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js +++ /dev/null @@ -1,124 +0,0 @@ - -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Console schema - */ - -var consoleSchema = Schema({ - name: String, - manufacturer: String, - released: Date -}); -var Console = mongoose.model('Console', consoleSchema); - -/** - * Game schema - */ - -var gameSchema = Schema({ - name: String, - developer: String, - released: Date, - consoles: [{ - type: Schema.Types.ObjectId, - ref: 'Console' - }] -}); -var Game = mongoose.model('Game', gameSchema); - -/** - * Connect to the console database on localhost with - * the default port (27017) - */ - -mongoose.connect('mongodb://localhost/console', function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - createData(); -}); - -/** - * Data generation - */ - -function createData() { - Console.create( - { - name: 'Nintendo 64', - manufacturer: 'Nintendo', - released: 'September 29, 1996' - }, - { - name: 'Super Nintendo', - manufacturer: 'Nintendo', - released: 'August 23, 1991' - }, - function(err, nintendo64, superNintendo) { - if (err) return done(err); - - Game.create( - { - name: 'Legend of Zelda: Ocarina of Time', - developer: 'Nintendo', - released: new Date('November 21, 1998'), - consoles: [nintendo64] - }, - { - name: 'Mario Kart', - developer: 'Nintendo', - released: 'September 1, 1992', - consoles: [superNintendo] - }, - function(err) { - if (err) return done(err); - example(); - } - ); - } - ); -} - -/** - * Population - */ - -function example() { - Game - .find({}) - .exec(function(err, games) { - if (err) return done(err); - - console.log('found %d games', games.length); - - var options = {path: 'consoles', select: 'name released -_id'}; - Game.populate(games, options, function(err, games) { - if (err) return done(err); - - games.forEach(function(game) { - console.log( - '"%s" was released for the %s on %s', - game.name, - game.consoles[0].name, - game.released.toLocaleDateString() - ); - }); - - done(); - }); - }); -} - -function done(err) { - if (err) console.error(err); - Console.remove(function() { - Game.remove(function() { - mongoose.disconnect(); - }); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js deleted file mode 100644 index 59cfd1e..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js +++ /dev/null @@ -1,138 +0,0 @@ - -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Console schema - */ - -var consoleSchema = Schema({ - name: String, - manufacturer: String, - released: Date -}); -var Console = mongoose.model('Console', consoleSchema); - -/** - * Game schema - */ - -var gameSchema = Schema({ - name: String, - developer: String, - released: Date, - consoles: [{ - type: Schema.Types.ObjectId, - ref: 'Console' - }] -}); -var Game = mongoose.model('Game', gameSchema); - -/** - * Connect to the console database on localhost with - * the default port (27017) - */ - -mongoose.connect('mongodb://localhost/console', function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - createData(); -}); - -/** - * Data generation - */ - -function createData() { - Console.create( - { - name: 'Nintendo 64', - manufacturer: 'Nintendo', - released: 'September 29, 1996' - }, - { - name: 'Super Nintendo', - manufacturer: 'Nintendo', - released: 'August 23, 1991' - }, - { - name: 'XBOX 360', - manufacturer: 'Microsoft', - released: 'November 22, 2005' - }, - function(err, nintendo64, superNintendo, xbox360) { - if (err) return done(err); - - Game.create( - { - name: 'Legend of Zelda: Ocarina of Time', - developer: 'Nintendo', - released: new Date('November 21, 1998'), - consoles: [nintendo64] - }, - { - name: 'Mario Kart', - developer: 'Nintendo', - released: 'September 1, 1992', - consoles: [superNintendo] - }, - { - name: 'Perfect Dark Zero', - developer: 'Rare', - released: 'November 17, 2005', - consoles: [xbox360] - }, - function(err) { - if (err) return done(err); - example(); - } - ); - } - ); -} - -/** - * Population - */ - -function example() { - Game - .find({}) - .populate({ - path: 'consoles', - match: {manufacturer: 'Nintendo'}, - select: 'name', - options: {comment: 'population'} - }) - .exec(function(err, games) { - if (err) return done(err); - - games.forEach(function(game) { - console.log( - '"%s" was released for the %s on %s', - game.name, - game.consoles.length ? game.consoles[0].name : '??', - game.released.toLocaleDateString() - ); - }); - - return done(); - }); -} - -/** - * Clean up - */ - -function done(err) { - if (err) console.error(err); - Console.remove(function() { - Game.remove(function() { - mongoose.disconnect(); - }); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js deleted file mode 100644 index ba849dc..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js +++ /dev/null @@ -1,106 +0,0 @@ - -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -console.log('Running mongoose version %s', mongoose.version); - -/** - * Console schema - */ - -var consoleSchema = Schema({ - name: String, - manufacturer: String, - released: Date -}); -var Console = mongoose.model('Console', consoleSchema); - -/** - * Game schema - */ - -var gameSchema = Schema({ - name: String, - developer: String, - released: Date, - consoles: [{ - type: Schema.Types.ObjectId, - ref: 'Console' - }] -}); -var Game = mongoose.model('Game', gameSchema); - -/** - * Connect to the console database on localhost with - * the default port (27017) - */ - -mongoose.connect('mongodb://localhost/console', function(err) { - // if we failed to connect, abort - if (err) throw err; - - // we connected ok - createData(); -}); - -/** - * Data generation - */ - -function createData() { - Console.create( - { - name: 'Nintendo 64', - manufacturer: 'Nintendo', - released: 'September 29, 1996' - }, - function(err, nintendo64) { - if (err) return done(err); - - Game.create( - { - name: 'Legend of Zelda: Ocarina of Time', - developer: 'Nintendo', - released: new Date('November 21, 1998'), - consoles: [nintendo64] - }, - function(err) { - if (err) return done(err); - example(); - } - ); - } - ); -} - -/** - * Population - */ - -function example() { - Game - .findOne({name: /^Legend of Zelda/}) - .populate('consoles') - .lean() // just return plain objects, not documents wrapped by mongoose - .exec(function(err, ocinara) { - if (err) return done(err); - - console.log( - '"%s" was released for the %s on %s', - ocinara.name, - ocinara.consoles[0].name, - ocinara.released.toLocaleDateString() - ); - - done(); - }); -} - -function done(err) { - if (err) console.error(err); - Console.remove(function() { - Game.remove(function() { - mongoose.disconnect(); - }); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json deleted file mode 100644 index 1983250..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "promise-example", - "private": "true", - "version": "0.0.0", - "description": "deps for promise example", - "main": "promise.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js deleted file mode 100644 index 40e2bf1..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js +++ /dev/null @@ -1,15 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js deleted file mode 100644 index 3f17206..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js +++ /dev/null @@ -1,94 +0,0 @@ -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)) - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)) - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)) - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)) - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)) - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) { - throw err; - } - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handle error - } - - // create a promise (get one from the query builder) - var prom = Person.find({age: {$lt: 1000}}).exec(); - - // add a callback on the promise. This will be called on both error and - // complete - prom.addBack(function() { - console.log('completed'); - }); - - // add a callback that is only called on complete (success) events - prom.addCallback(function() { - console.log('Successful Completion!'); - }); - - // add a callback that is only called on err (rejected) events - prom.addErrback(function() { - console.log('Fail Boat'); - }); - - // you can chain things just like in the promise/A+ spec - // note: each then() is returning a new promise, so the above methods - // that we defined will all fire after the initial promise is fulfilled - prom.then(function(people) { - // just getting the stuff for the next query - var ids = people.map(function(p) { - return p._id; - }); - - // return the next promise - return Person.find({_id: {$nin: ids}}).exec(); - }).then(function(oldest) { - console.log('Oldest person is: %s', oldest); - }).then(cleanup); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json deleted file mode 100644 index 1a3450a..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "query-builder-example", - "private": "true", - "version": "0.0.0", - "description": "deps for query builder example", - "main": "querybuilder.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js deleted file mode 100644 index 40e2bf1..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js +++ /dev/null @@ -1,15 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js deleted file mode 100644 index 6f8645b..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js +++ /dev/null @@ -1,79 +0,0 @@ - -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)) - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)) - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)) - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)) - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)) - } -]; - - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) throw err; - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) throw err; - - // when querying data, instead of providing a callback, you can instead - // leave that off and get a query object returned - var query = Person.find({age: {$lt: 1000}}); - - // this allows you to continue applying modifiers to it - query.sort('birthday'); - query.select('name'); - - // you can chain them together as well - // a full list of methods can be found: - // http://mongoosejs.com/docs/api.html#query-js - query.where('age').gt(21); - - // finally, when ready to execute the query, call the exec() function - query.exec(function(err, results) { - if (err) throw err; - - console.log(results); - - cleanup(); - }); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json deleted file mode 100644 index 927dfd2..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "replica-set-example", - "private": "true", - "version": "0.0.0", - "description": "deps for replica set example", - "main": "querybuilder.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { "async": "*" }, - "repository": "", - "author": "", - "license": "BSD" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js deleted file mode 100644 index 40e2bf1..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js +++ /dev/null @@ -1,15 +0,0 @@ - -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date - }); - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js deleted file mode 100644 index 9ebac1b..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js +++ /dev/null @@ -1,71 +0,0 @@ - -// import async to make control flow simplier -var async = require('async'); - -// import the rest of the normal stuff -var mongoose = require('../../lib'); - -require('./person.js')(); - -var Person = mongoose.model('Person'); - -// define some dummy data -var data = [ - { - name: 'bill', - age: 25, - birthday: new Date().setFullYear((new Date().getFullYear() - 25)) - }, - { - name: 'mary', - age: 30, - birthday: new Date().setFullYear((new Date().getFullYear() - 30)) - }, - { - name: 'bob', - age: 21, - birthday: new Date().setFullYear((new Date().getFullYear() - 21)) - }, - { - name: 'lilly', - age: 26, - birthday: new Date().setFullYear((new Date().getFullYear() - 26)) - }, - { - name: 'alucard', - age: 1000, - birthday: new Date().setFullYear((new Date().getFullYear() - 1000)) - } -]; - - -// to connect to a replica set, pass in the comma delimited uri and optionally -// any connection options such as the rs_name. -var opts = { - replSet: {rs_name: 'rs0'} -}; -mongoose.connect('mongodb://localhost:27018/persons,localhost:27019,localhost:27020', opts, function(err) { - if (err) throw err; - - // create all of the dummy people - async.each(data, function(item, cb) { - Person.create(item, cb); - }, function(err) { - if (err) { - // handle error - } - - // create and delete some data - var prom = Person.find({age: {$lt: 1000}}).exec(); - - prom.then(function(people) { - console.log('young people: %s', people); - }).then(cleanup); - }); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js deleted file mode 100644 index 5bc99ae..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Module dependencies. - */ - -var mongoose = require('../../lib'), - Schema = mongoose.Schema; - -/** - * Schema definition - */ - -// recursive embedded-document schema - -var Comment = new Schema(); - -Comment.add({ - title: { - type: String, - index: true - }, - date: Date, - body: String, - comments: [Comment] -}); - -var BlogPost = new Schema({ - title: { - type: String, - index: true - }, - slug: { - type: String, - lowercase: true, - trim: true - }, - date: Date, - buf: Buffer, - comments: [Comment], - creator: Schema.ObjectId -}); - -var Person = new Schema({ - name: { - first: String, - last: String - }, - email: { - type: String, - required: true, - index: { - unique: true, - sparse: true - } - }, - alive: Boolean -}); - -/** - * Accessing a specific schema type by key - */ - -BlogPost.path('date') -.default(function() { - return new Date(); -}) -.set(function(v) { - return v === 'now' ? new Date() : v; -}); - -/** - * Pre hook. - */ - -BlogPost.pre('save', function(next, done) { - /* global emailAuthor */ - emailAuthor(done); // some async function - next(); -}); - -/** - * Methods - */ - -BlogPost.methods.findCreator = function(callback) { - return this.db.model('Person').findById(this.creator, callback); -}; - -BlogPost.statics.findByTitle = function(title, callback) { - return this.find({title: title}, callback); -}; - -BlogPost.methods.expressiveQuery = function(creator, date, callback) { - return this.find('creator', creator).where('date').gte(date).run(callback); -}; - -/** - * Plugins - */ - -function slugGenerator(options) { - options = options || {}; - var key = options.key || 'title'; - - return function slugGenerator(schema) { - schema.path(key).set(function(v) { - this.slug = v.toLowerCase().replace(/[^a-z0-9]/g, '').replace(/-+/g, ''); - return v; - }); - }; -} - -BlogPost.plugin(slugGenerator()); - -/** - * Define model. - */ - -mongoose.model('BlogPost', BlogPost); -mongoose.model('Person', Person); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js deleted file mode 100644 index 284b478..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js +++ /dev/null @@ -1,27 +0,0 @@ - -// modules -var mongoose = require('../../../lib'); -var Schema = mongoose.Schema; - -// parse json -var raw = require('./schema.json'); - -// create a schema -var timeSignatureSchema = Schema(raw); - -// compile the model -var TimeSignature = mongoose.model('TimeSignatures', timeSignatureSchema); - -// create a TimeSignature document -var threeFour = new TimeSignature({ - count: 3, - unit: 4, - description: '3/4', - additive: false, - created: new Date, - links: ['http://en.wikipedia.org/wiki/Time_signature'], - user_id: '518d31a0ef32bbfa853a9814' -}); - -// print its description -console.log(threeFour); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json deleted file mode 100644 index 5afc626..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "count": "number", - "unit": "number", - "description": "string", - "links": ["string"], - "created": "date", - "additive": "boolean", - "user_id": "ObjectId" -} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js deleted file mode 100644 index a93b8c6..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js +++ /dev/null @@ -1,20 +0,0 @@ -// import the necessary modules -var mongoose = require('../../lib'); -var Schema = mongoose.Schema; - -// create an export function to encapsulate the model creation -module.exports = function() { - // define schema - var PersonSchema = new Schema({ - name: String, - age: Number, - birthday: Date - }); - - // define a static - PersonSchema.statics.findPersonByName = function(name, cb) { - this.find({name: new RegExp(name, 'i')}, cb); - }; - - mongoose.model('Person', PersonSchema); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js deleted file mode 100644 index 610b2aa..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js +++ /dev/null @@ -1,41 +0,0 @@ -var mongoose = require('../../lib'); - - -// import the schema -require('./person.js')(); - -// grab the person model object -var Person = mongoose.model('Person'); - -// connect to a server to do a quick write / read example - -mongoose.connect('mongodb://localhost/persons', function(err) { - if (err) { - throw err; - } - - Person.create({name: 'bill', age: 25, birthday: new Date().setFullYear((new Date().getFullYear() - 25))}, - function(err, bill) { - if (err) { - throw err; - } - console.log('People added to db: %s', bill.toString()); - - // using the static - Person.findPersonByName('bill', function(err, result) { - if (err) { - throw err; - } - - console.log(result); - cleanup(); - }); - } - ); -}); - -function cleanup() { - Person.remove(function() { - mongoose.disconnect(); - }); -} |