mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
118
node_modules/mongoose/lib/index.js
generated
vendored
118
node_modules/mongoose/lib/index.js
generated
vendored
@@ -4,22 +4,23 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Schema = require('./schema')
|
||||
, SchemaType = require('./schematype')
|
||||
, VirtualType = require('./virtualtype')
|
||||
, STATES = require('./connectionstate')
|
||||
, Types = require('./types')
|
||||
, Query = require('./query')
|
||||
, Promise = require('./promise')
|
||||
, Model = require('./model')
|
||||
, Document = require('./document')
|
||||
, utils = require('./utils')
|
||||
, format = utils.toCollectionName
|
||||
, mongodb = require('mongodb')
|
||||
, pkg = require('../package.json')
|
||||
var Schema = require('./schema'),
|
||||
SchemaType = require('./schematype'),
|
||||
VirtualType = require('./virtualtype'),
|
||||
STATES = require('./connectionstate'),
|
||||
Types = require('./types'),
|
||||
Query = require('./query'),
|
||||
Model = require('./model'),
|
||||
Document = require('./document'),
|
||||
utils = require('./utils'),
|
||||
format = utils.toCollectionName,
|
||||
pkg = require('../package.json');
|
||||
|
||||
var querystring = require('querystring');
|
||||
|
||||
var Aggregate = require('./aggregate');
|
||||
var PromiseProvider = require('./promise_provider');
|
||||
|
||||
/**
|
||||
* Mongoose constructor.
|
||||
*
|
||||
@@ -29,7 +30,7 @@ var querystring = require('querystring');
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Mongoose () {
|
||||
function Mongoose() {
|
||||
this.connections = [];
|
||||
this.plugins = [];
|
||||
this.models = {};
|
||||
@@ -40,7 +41,7 @@ function Mongoose () {
|
||||
};
|
||||
var conn = this.createConnection(); // default connection
|
||||
conn.models = this.models;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose connection states for user-land
|
||||
@@ -57,12 +58,14 @@ Mongoose.prototype.STATES = STATES;
|
||||
*
|
||||
* mongoose.set('debug', true) // enable logging collection methods + arguments to the console
|
||||
*
|
||||
* mongoose.set('debug', function(collectionName, methodName, arg1, arg2...) {}); // use custom function to log collection methods + arguments
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {String} value
|
||||
* @param {String|Function} value
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.set = function (key, value) {
|
||||
Mongoose.prototype.set = function(key, value) {
|
||||
if (arguments.length == 1) {
|
||||
return this.options[key];
|
||||
}
|
||||
@@ -116,7 +119,7 @@ var checkReplicaSetInUri = function(uri) {
|
||||
if (obj && obj.replicaSet) {
|
||||
isReplicaSet = true;
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -168,13 +171,16 @@ var checkReplicaSetInUri = function(uri) {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.createConnection = function () {
|
||||
Mongoose.prototype.createConnection = function(uri, options) {
|
||||
var conn = new Connection(this);
|
||||
this.connections.push(conn);
|
||||
|
||||
if (arguments.length) {
|
||||
if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
|
||||
conn.openSet.apply(conn, arguments);
|
||||
} else if (options && options.replset &&
|
||||
(options.replset.replicaSet || options.replset.rs_name)) {
|
||||
conn.openSet.apply(conn, arguments);
|
||||
} else {
|
||||
conn.open.apply(conn, arguments);
|
||||
}
|
||||
@@ -195,7 +201,7 @@ Mongoose.prototype.createConnection = function () {
|
||||
* mongoose.connect('mongodb://user:pass@localhost:port/database');
|
||||
*
|
||||
* // replica sets
|
||||
* var uri = 'mongodb://user:pass@localhost:port/database,mongodb://anotherhost:port,mongodb://yetanother:port';
|
||||
* var uri = 'mongodb://user:pass@localhost:port,anotherhost:port,yetanother:port/mydatabase';
|
||||
* mongoose.connect(uri);
|
||||
*
|
||||
* // with options
|
||||
@@ -234,12 +240,12 @@ Mongoose.prototype.connect = function() {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.disconnect = function (fn) {
|
||||
var count = this.connections.length
|
||||
, error
|
||||
Mongoose.prototype.disconnect = function(fn) {
|
||||
var count = this.connections.length,
|
||||
error;
|
||||
|
||||
this.connections.forEach(function(conn){
|
||||
conn.close(function(err){
|
||||
this.connections.forEach(function(conn) {
|
||||
conn.close(function(err) {
|
||||
if (error) return;
|
||||
|
||||
if (err) {
|
||||
@@ -295,13 +301,13 @@ Mongoose.prototype.disconnect = function (fn) {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.model = function (name, schema, collection, skipInit) {
|
||||
Mongoose.prototype.model = function(name, schema, collection, skipInit) {
|
||||
if ('string' == typeof schema) {
|
||||
collection = schema;
|
||||
schema = false;
|
||||
}
|
||||
|
||||
if (utils.isObject(schema) && !(schema instanceof Schema)) {
|
||||
if (utils.isObject(schema) && !(schema.instanceOfSchema)) {
|
||||
schema = new Schema(schema);
|
||||
}
|
||||
|
||||
@@ -336,7 +342,7 @@ Mongoose.prototype.model = function (name, schema, collection, skipInit) {
|
||||
// connection.model() may be passing a different schema for
|
||||
// an existing model name. in this case don't read from cache.
|
||||
if (this.models[name] && false !== options.cache) {
|
||||
if (schema instanceof Schema && schema != this.models[name].schema) {
|
||||
if (schema && schema.instanceOfSchema && schema != this.models[name].schema) {
|
||||
throw new mongoose.Error.OverwriteModelError(name);
|
||||
}
|
||||
|
||||
@@ -380,7 +386,7 @@ Mongoose.prototype.model = function (name, schema, collection, skipInit) {
|
||||
}
|
||||
|
||||
return this.models[name] = model;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of model names created on this instance of Mongoose.
|
||||
@@ -393,10 +399,10 @@ Mongoose.prototype.model = function (name, schema, collection, skipInit) {
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
Mongoose.prototype.modelNames = function () {
|
||||
Mongoose.prototype.modelNames = function() {
|
||||
var names = Object.keys(this.models);
|
||||
return names;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies global plugins to `schema`.
|
||||
@@ -405,11 +411,11 @@ Mongoose.prototype.modelNames = function () {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Mongoose.prototype._applyPlugins = function (schema) {
|
||||
Mongoose.prototype._applyPlugins = function(schema) {
|
||||
for (var i = 0, l = this.plugins.length; i < l; i++) {
|
||||
schema.plugin(this.plugins[i][0], this.plugins[i][1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Declares a global plugin executed on all Schemas.
|
||||
@@ -423,7 +429,7 @@ Mongoose.prototype._applyPlugins = function (schema) {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.plugin = function (fn, opts) {
|
||||
Mongoose.prototype.plugin = function(fn, opts) {
|
||||
this.plugins.push([fn, opts]);
|
||||
return this;
|
||||
};
|
||||
@@ -444,7 +450,7 @@ Mongoose.prototype.plugin = function (fn, opts) {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.__defineGetter__('connection', function(){
|
||||
Mongoose.prototype.__defineGetter__('connection', function() {
|
||||
return this.connections[0];
|
||||
});
|
||||
|
||||
@@ -452,19 +458,28 @@ Mongoose.prototype.__defineGetter__('connection', function(){
|
||||
* Driver depentend APIs
|
||||
*/
|
||||
|
||||
var driver = global.MONGOOSE_DRIVER_PATH || 'node-mongodb-native';
|
||||
var driver = global.MONGOOSE_DRIVER_PATH || './drivers/node-mongodb-native';
|
||||
|
||||
/*!
|
||||
* Connection
|
||||
*/
|
||||
|
||||
var Connection = require('./drivers/' + driver + '/connection');
|
||||
var Connection = require(driver + '/connection');
|
||||
|
||||
/*!
|
||||
* Collection
|
||||
*/
|
||||
|
||||
var Collection = require('./drivers/' + driver + '/collection');
|
||||
var Collection = require(driver + '/collection');
|
||||
|
||||
/**
|
||||
* The Mongoose Aggregate constructor
|
||||
*
|
||||
* @method Aggregate
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.Aggregate = Aggregate;
|
||||
|
||||
/**
|
||||
* The Mongoose Collection constructor
|
||||
@@ -599,7 +614,23 @@ Mongoose.prototype.Query = Query;
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.Promise = Promise;
|
||||
Object.defineProperty(Mongoose.prototype, 'Promise', {
|
||||
get: function() {
|
||||
return PromiseProvider.get();
|
||||
},
|
||||
set: function(lib) {
|
||||
PromiseProvider.set(lib);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Storage layer for mongoose promises
|
||||
*
|
||||
* @method PromiseProvider
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.PromiseProvider = PromiseProvider;
|
||||
|
||||
/**
|
||||
* The Mongoose [Model](#model_Model) constructor.
|
||||
@@ -619,6 +650,15 @@ Mongoose.prototype.Model = Model;
|
||||
|
||||
Mongoose.prototype.Document = Document;
|
||||
|
||||
/**
|
||||
* The Mongoose DocumentProvider constructor.
|
||||
*
|
||||
* @method DocumentProvider
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Mongoose.prototype.DocumentProvider = require('./document_provider');
|
||||
|
||||
/**
|
||||
* The [MongooseError](#error_MongooseError) constructor.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user