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:
4
node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js
generated
vendored
4
node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js
generated
vendored
@@ -13,7 +13,7 @@ var ReadPref = mongodb.ReadPreference;
|
||||
* @param {Array} [tags]
|
||||
*/
|
||||
|
||||
module.exports = function readPref (pref, tags) {
|
||||
module.exports = function readPref(pref, tags) {
|
||||
if (Array.isArray(pref)) {
|
||||
tags = pref[1];
|
||||
pref = pref[0];
|
||||
@@ -42,4 +42,4 @@ module.exports = function readPref (pref, tags) {
|
||||
}
|
||||
|
||||
return new ReadPref(pref, tags);
|
||||
}
|
||||
};
|
||||
|
||||
93
node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
generated
vendored
93
node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
generated
vendored
@@ -3,10 +3,9 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var MongooseCollection = require('../../collection')
|
||||
, Collection = require('mongodb').Collection
|
||||
, STATES = require('../../connectionstate')
|
||||
, utils = require('../../utils')
|
||||
var MongooseCollection = require('../../collection'),
|
||||
Collection = require('mongodb').Collection,
|
||||
utils = require('../../utils');
|
||||
|
||||
/**
|
||||
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) collection implementation.
|
||||
@@ -17,7 +16,7 @@ var MongooseCollection = require('../../collection')
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function NativeCollection () {
|
||||
function NativeCollection() {
|
||||
this.collection = null;
|
||||
MongooseCollection.apply(this, arguments);
|
||||
}
|
||||
@@ -34,7 +33,7 @@ NativeCollection.prototype.__proto__ = MongooseCollection.prototype;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
NativeCollection.prototype.onOpen = function () {
|
||||
NativeCollection.prototype.onOpen = function() {
|
||||
var self = this;
|
||||
|
||||
// always get a new collection in case the user changed host:port
|
||||
@@ -46,7 +45,7 @@ NativeCollection.prototype.onOpen = function () {
|
||||
}
|
||||
|
||||
// capped
|
||||
return self.conn.db.collection(self.name, function (err, c) {
|
||||
return self.conn.db.collection(self.name, function(err, c) {
|
||||
if (err) return callback(err);
|
||||
|
||||
// discover if this collection exists and if it is capped
|
||||
@@ -61,10 +60,10 @@ NativeCollection.prototype.onOpen = function () {
|
||||
if (doc.options && doc.options.capped) {
|
||||
callback(null, c);
|
||||
} else {
|
||||
var msg = 'A non-capped collection exists with the name: '+ self.name +'\n\n'
|
||||
var msg = 'A non-capped collection exists with the name: ' + self.name + '\n\n'
|
||||
+ ' To use this collection as a capped collection, please '
|
||||
+ 'first convert it.\n'
|
||||
+ ' http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-Convertingacollectiontocapped'
|
||||
+ ' http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-Convertingacollectiontocapped';
|
||||
err = new Error(msg);
|
||||
callback(err);
|
||||
}
|
||||
@@ -77,7 +76,7 @@ NativeCollection.prototype.onOpen = function () {
|
||||
});
|
||||
});
|
||||
|
||||
function callback (err, collection) {
|
||||
function callback(err, collection) {
|
||||
if (err) {
|
||||
// likely a strict mode error
|
||||
self.conn.emit('error', err);
|
||||
@@ -85,7 +84,7 @@ NativeCollection.prototype.onOpen = function () {
|
||||
self.collection = collection;
|
||||
MongooseCollection.prototype.onOpen.call(self);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -94,7 +93,7 @@ NativeCollection.prototype.onOpen = function () {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
NativeCollection.prototype.onClose = function () {
|
||||
NativeCollection.prototype.onClose = function() {
|
||||
MongooseCollection.prototype.onClose.call(this);
|
||||
};
|
||||
|
||||
@@ -109,34 +108,28 @@ for (var i in Collection.prototype) {
|
||||
if (typeof Collection.prototype[i] !== 'function') {
|
||||
continue;
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(function(i){
|
||||
NativeCollection.prototype[i] = function () {
|
||||
(function(i) {
|
||||
NativeCollection.prototype[i] = function() {
|
||||
if (this.buffer) {
|
||||
this.addQueue(i, arguments);
|
||||
return;
|
||||
}
|
||||
|
||||
var collection = this.collection
|
||||
, args = arguments
|
||||
, self = this
|
||||
, debug = self.conn.base.options.debug;
|
||||
var collection = this.collection,
|
||||
args = arguments,
|
||||
self = this,
|
||||
debug = self.conn.base.options.debug;
|
||||
|
||||
if (debug) {
|
||||
if ('function' === typeof debug) {
|
||||
debug.apply(debug
|
||||
, [self.name, i].concat(utils.args(args, 0, args.length-1)));
|
||||
, [self.name, i].concat(utils.args(args, 0, args.length - 1)));
|
||||
} else {
|
||||
console.error('\x1B[0;36mMongoose:\x1B[0m %s.%s(%s) %s %s %s'
|
||||
, self.name
|
||||
, i
|
||||
, print(args[0])
|
||||
, print(args[1])
|
||||
, print(args[2])
|
||||
, print(args[3]))
|
||||
this.$print(self.name, i, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,30 +138,50 @@ for (var i in Collection.prototype) {
|
||||
})(i);
|
||||
}
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Debug print helper
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function print (arg) {
|
||||
NativeCollection.prototype.$print = function(name, i, args) {
|
||||
console.error(
|
||||
'\x1B[0;36mMongoose:\x1B[0m %s.%s(%s) %s %s %s',
|
||||
name,
|
||||
i,
|
||||
this.$format(args[0]),
|
||||
this.$format(args[1]),
|
||||
this.$format(args[2]),
|
||||
this.$format(args[3]));
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatter for debug print args
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
NativeCollection.prototype.$format = function(arg) {
|
||||
var type = typeof arg;
|
||||
if ('function' === type || 'undefined' === type) return '';
|
||||
return format(arg);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Debug print helper
|
||||
*/
|
||||
|
||||
function format (obj, sub) {
|
||||
function format(obj, sub) {
|
||||
var x = utils.clone(obj, { retainKeyOrder: 1 });
|
||||
var representation;
|
||||
if (x) {
|
||||
if ('Binary' === x.constructor.name) {
|
||||
x = '[object Buffer]';
|
||||
} else if ('ObjectID' === x.constructor.name) {
|
||||
var representation = 'ObjectId("' + x.toHexString() + '")';
|
||||
representation = 'ObjectId("' + x.toHexString() + '")';
|
||||
x = { inspect: function() { return representation; } };
|
||||
} else if ('Date' === x.constructor.name) {
|
||||
var representation = 'new Date("' + x.toUTCString() + '")';
|
||||
representation = 'new Date("' + x.toUTCString() + '")';
|
||||
x = { inspect: function() { return representation; } };
|
||||
} else if ('Object' === x.constructor.name) {
|
||||
var keys = Object.keys(x);
|
||||
@@ -182,18 +195,18 @@ function format (obj, sub) {
|
||||
} else if ('Object' === x[key].constructor.name) {
|
||||
x[key] = format(x[key], true);
|
||||
} else if ('ObjectID' === x[key].constructor.name) {
|
||||
;(function(x){
|
||||
(function(x) {
|
||||
var representation = 'ObjectId("' + x[key].toHexString() + '")';
|
||||
x[key] = { inspect: function() { return representation; } };
|
||||
})(x)
|
||||
})(x);
|
||||
} else if ('Date' === x[key].constructor.name) {
|
||||
;(function(x){
|
||||
(function(x) {
|
||||
var representation = 'new Date("' + x[key].toUTCString() + '")';
|
||||
x[key] = { inspect: function() { return representation; } };
|
||||
})(x)
|
||||
})(x);
|
||||
} else if (Array.isArray(x[key])) {
|
||||
x[key] = x[key].map(function (o) {
|
||||
return format(o, true)
|
||||
x[key] = x[key].map(function(o) {
|
||||
return format(o, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -205,7 +218,7 @@ function format (obj, sub) {
|
||||
return require('util')
|
||||
.inspect(x, false, 10, true)
|
||||
.replace(/\n/g, '')
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.replace(/\s{2,}/g, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
111
node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js
generated
vendored
111
node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js
generated
vendored
@@ -2,14 +2,13 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var MongooseConnection = require('../../connection')
|
||||
, mongo = require('mongodb')
|
||||
, Db = mongo.Db
|
||||
, Server = mongo.Server
|
||||
, Mongos = mongo.Mongos
|
||||
, STATES = require('../../connectionstate')
|
||||
, ReplSetServers = mongo.ReplSet
|
||||
, utils = require('../../utils');
|
||||
var MongooseConnection = require('../../connection'),
|
||||
mongo = require('mongodb'),
|
||||
Db = mongo.Db,
|
||||
Server = mongo.Server,
|
||||
Mongos = mongo.Mongos,
|
||||
STATES = require('../../connectionstate'),
|
||||
ReplSetServers = mongo.ReplSet;
|
||||
|
||||
/**
|
||||
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
|
||||
@@ -21,7 +20,7 @@ var MongooseConnection = require('../../connection')
|
||||
function NativeConnection() {
|
||||
MongooseConnection.apply(this, arguments);
|
||||
this._listening = false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the possible connection states.
|
||||
@@ -44,16 +43,18 @@ NativeConnection.prototype.__proto__ = MongooseConnection.prototype;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
NativeConnection.prototype.doOpen = function (fn) {
|
||||
if (this.db) {
|
||||
mute(this);
|
||||
NativeConnection.prototype.doOpen = function(fn) {
|
||||
var server = new Server(this.host, this.port, this.options.server);
|
||||
|
||||
if (this.options && this.options.mongos) {
|
||||
var mongos = new Mongos([server], this.options.mongos);
|
||||
this.db = new Db(this.name, mongos, this.options.db);
|
||||
} else {
|
||||
this.db = new Db(this.name, server, this.options.db);
|
||||
}
|
||||
|
||||
var server = new Server(this.host, this.port, this.options.server);
|
||||
this.db = new Db(this.name, server, this.options.db);
|
||||
|
||||
var self = this;
|
||||
this.db.open(function (err) {
|
||||
this.db.open(function(err) {
|
||||
if (err) return fn(err);
|
||||
listen(self);
|
||||
fn();
|
||||
@@ -72,7 +73,7 @@ NativeConnection.prototype.doOpen = function (fn) {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
NativeConnection.prototype.useDb = function (name) {
|
||||
NativeConnection.prototype.useDb = function(name) {
|
||||
// we have to manually copy all of the attributes...
|
||||
var newConn = new this.constructor();
|
||||
newConn.name = name;
|
||||
@@ -106,7 +107,7 @@ NativeConnection.prototype.useDb = function (name) {
|
||||
this.once('connected', wireup);
|
||||
}
|
||||
|
||||
function wireup () {
|
||||
function wireup() {
|
||||
newConn.db = self.db.db(name);
|
||||
newConn.onOpen();
|
||||
// setup the events appropriately
|
||||
@@ -126,11 +127,11 @@ NativeConnection.prototype.useDb = function (name) {
|
||||
* Register listeners for important events and bubble appropriately.
|
||||
*/
|
||||
|
||||
function listen (conn) {
|
||||
function listen(conn) {
|
||||
if (conn._listening) return;
|
||||
conn._listening = true;
|
||||
|
||||
conn.db.on('close', function(){
|
||||
conn.db.on('close', function() {
|
||||
if (conn._closeCalled) return;
|
||||
|
||||
// the driver never emits an `open` event. auto_reconnect still
|
||||
@@ -143,18 +144,18 @@ function listen (conn) {
|
||||
}
|
||||
conn.onClose();
|
||||
});
|
||||
conn.db.on('error', function(err){
|
||||
conn.db.on('error', function(err) {
|
||||
conn.emit('error', err);
|
||||
});
|
||||
conn.db.on('reconnect', function() {
|
||||
conn.readyState = STATES.connected;
|
||||
conn.emit('reconnected');
|
||||
});
|
||||
conn.db.on('timeout', function(err){
|
||||
conn.db.on('timeout', function(err) {
|
||||
var error = new Error(err && err.err || 'connection timeout');
|
||||
conn.emit('error', error);
|
||||
});
|
||||
conn.db.on('open', function (err, db) {
|
||||
conn.db.on('open', function(err, db) {
|
||||
if (STATES.disconnected === conn.readyState && db && db.databaseName) {
|
||||
conn.readyState = STATES.connected;
|
||||
conn.emit('reconnected');
|
||||
@@ -165,20 +166,6 @@ function listen (conn) {
|
||||
});
|
||||
}
|
||||
|
||||
/*!
|
||||
* Remove listeners registered in `listen`
|
||||
*/
|
||||
|
||||
function mute (conn) {
|
||||
if (!conn.db) throw new Error('missing db');
|
||||
conn.db.removeAllListeners("close");
|
||||
conn.db.removeAllListeners("error");
|
||||
conn.db.removeAllListeners("timeout");
|
||||
conn.db.removeAllListeners("open");
|
||||
conn.db.removeAllListeners("fullsetup");
|
||||
conn._listening = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a connection to a MongoDB ReplicaSet.
|
||||
*
|
||||
@@ -189,30 +176,26 @@ function mute (conn) {
|
||||
* @return {Connection} this
|
||||
*/
|
||||
|
||||
NativeConnection.prototype.doOpenSet = function (fn) {
|
||||
if (this.db) {
|
||||
mute(this);
|
||||
}
|
||||
NativeConnection.prototype.doOpenSet = function(fn) {
|
||||
var servers = [],
|
||||
self = this;
|
||||
|
||||
var servers = []
|
||||
, self = this;
|
||||
|
||||
this.hosts.forEach(function (server) {
|
||||
this.hosts.forEach(function(server) {
|
||||
var host = server.host || server.ipc;
|
||||
var port = server.port || 27017;
|
||||
servers.push(new Server(host, port, self.options.server));
|
||||
})
|
||||
});
|
||||
|
||||
var server = this.options.mongos
|
||||
? new Mongos(servers, this.options.mongos)
|
||||
: new ReplSetServers(servers, this.options.replset);
|
||||
: new ReplSetServers(servers, this.options.replset || this.options.replSet);
|
||||
this.db = new Db(this.name, server, this.options.db);
|
||||
|
||||
this.db.on('fullsetup', function () {
|
||||
self.emit('fullsetup')
|
||||
this.db.on('fullsetup', function() {
|
||||
self.emit('fullsetup');
|
||||
});
|
||||
|
||||
this.db.open(function (err) {
|
||||
this.db.open(function(err) {
|
||||
if (err) return fn(err);
|
||||
fn();
|
||||
listen(self);
|
||||
@@ -229,11 +212,10 @@ NativeConnection.prototype.doOpenSet = function (fn) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
NativeConnection.prototype.doClose = function (fn) {
|
||||
this.db.close();
|
||||
if (fn) fn();
|
||||
NativeConnection.prototype.doClose = function(fn) {
|
||||
this.db.close(fn);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares default connection options for the node-mongodb-native driver.
|
||||
@@ -245,17 +227,17 @@ NativeConnection.prototype.doClose = function (fn) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
NativeConnection.prototype.parseOptions = function (passed, connStrOpts) {
|
||||
NativeConnection.prototype.parseOptions = function(passed, connStrOpts) {
|
||||
var o = passed || {};
|
||||
o.db || (o.db = {});
|
||||
o.auth || (o.auth = {});
|
||||
o.server || (o.server = {});
|
||||
o.replset || (o.replset = {});
|
||||
o.replset || (o.replset = o.replSet) || (o.replset = {});
|
||||
o.server.socketOptions || (o.server.socketOptions = {});
|
||||
o.replset.socketOptions || (o.replset.socketOptions = {});
|
||||
|
||||
var opts = connStrOpts || {};
|
||||
Object.keys(opts).forEach(function (name) {
|
||||
Object.keys(opts).forEach(function(name) {
|
||||
switch (name) {
|
||||
case 'ssl':
|
||||
case 'poolSize':
|
||||
@@ -321,8 +303,8 @@ NativeConnection.prototype.parseOptions = function (passed, connStrOpts) {
|
||||
}
|
||||
break;
|
||||
case 'readPreference':
|
||||
if ('undefined' == typeof o.db.read_preference) {
|
||||
o.db.read_preference = opts[name];
|
||||
if ('undefined' == typeof o.db.readPreference) {
|
||||
o.db.readPreference = opts[name];
|
||||
}
|
||||
break;
|
||||
case 'readPreferenceTags':
|
||||
@@ -331,17 +313,12 @@ NativeConnection.prototype.parseOptions = function (passed, connStrOpts) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (!('auto_reconnect' in o.server)) {
|
||||
o.server.auto_reconnect = true;
|
||||
}
|
||||
|
||||
if (!o.db.read_preference) {
|
||||
// read from primaries by default
|
||||
o.db.read_preference = 'primary';
|
||||
}
|
||||
|
||||
// mongoose creates its own ObjectIds
|
||||
o.db.forceServerObjectId = false;
|
||||
|
||||
@@ -353,7 +330,7 @@ NativeConnection.prototype.parseOptions = function (passed, connStrOpts) {
|
||||
|
||||
validate(o);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Validates the driver db options.
|
||||
@@ -361,7 +338,7 @@ NativeConnection.prototype.parseOptions = function (passed, connStrOpts) {
|
||||
* @param {Object} o
|
||||
*/
|
||||
|
||||
function validate (o) {
|
||||
function validate(o) {
|
||||
if (-1 === o.db.w || 0 === o.db.w) {
|
||||
if (o.db.journal || o.db.fsync || o.db.safe) {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user