Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/mongodb/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var Collection = require('./collection').Collection,
* @return {Function} Constructor for Admin type.
*/
function Admin(db) {
if(!(this instanceof Admin)) return new Admin(db);

this.db = db;
};

Expand Down
4 changes: 3 additions & 1 deletion lib/mongodb/bson/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var bson = require('./bson');
* @param {Number} [subType] the option binary type.
* @return {Grid}
*/
function Binary(buffer, subType) {
function Binary(buffer, subType) {
if(!(this instanceof Binary)) return new Binary(buffer, subType);

this._bsontype = 'Binary';

if(buffer instanceof Number) {
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @return {Code}
*/
function Code(code, scope) {
if(!(this instanceof Code)) return new Code(code, scope);

this._bsontype = 'Code';
this.code = code;
this.scope = scope == null ? {} : scope;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/db_ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @return {DBRef}
*/
function DBRef(namespace, oid, db) {
if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db);

this._bsontype = 'DBRef';
this.namespace = namespace;
this.oid = oid;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/double.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @return {Double}
*/
function Double(value) {
if(!(this instanceof Double)) return new Double(value);

this._bsontype = 'Double';
this.value = value;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/long.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @param {Number} high the high (signed) 32 bits of the Long.
*/
function Long(low, high) {
if(!(this instanceof Long)) return new Long(low, high);

this._bsontype = 'Long';
/**
* @type {number}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/max_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @return {MaxKey}
*/
function MaxKey() {
if(!(this instanceof MaxKey)) return new MaxKey();

this._bsontype = 'MaxKey';
}

Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/min_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @return {MinKey}
*/
function MinKey() {
if(!(this instanceof MinKey)) return new MinKey();

this._bsontype = 'MinKey';
}

Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/objectid.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$");
* @return {Object} instance of ObjectID.
*/
function ObjectID(id) {
if(!(this instanceof ObjectID)) return new ObjectID(id);

this._bsontype = 'ObjectID';

var self = this;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @return {Symbol}
*/
function Symbol(value) {
if(!(this instanceof Symbol)) return new Symbol(value);

this._bsontype = 'Symbol';
this.value = value;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/bson/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @param {Number} high the high (signed) 32 bits of the Timestamp.
*/
function Timestamp(low, high) {
if(!(this instanceof Timestamp)) return new Timestamp(low, high);

this._bsontype = 'Timestamp';
/**
* @type {number}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var toString = Object.prototype.toString;
* @return {Object} a collection instance.
*/
function Collection (db, collectionName, pkFactory, options) {
if(!(this instanceof Collection)) return new Collection(db, collectionName, pkFactory, options);

checkCollectionName(collectionName);

this.db = db;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/connection/repl_set_servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const STATE_ROLLBACK = 9;
*
*/
var ReplSetServers = exports.ReplSetServers = function(servers, options) {
if(!(this instanceof ReplSetServers)) return new ReplSetServers(server, options);

var self = this;
// Contains the master server entry
this.options = options == null ? {} : options;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/connection/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var Connection = require('./connection').Connection,
inherits = require('util').inherits;

var Server = exports.Server = function(host, port, options) {
if(!(this instanceof Server)) return new Server(host, port, options);

var self = this;
this.host = host;
this.port = port;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/cursorstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var Stream = require('stream').Stream;
* @return {Stream}
*/
function CursorStream(cursor) {
if(!(this instanceof CursorStream)) return new CursorStream(cursor);

Stream.call(this);

this.readable = true;
Expand Down
3 changes: 3 additions & 0 deletions lib/mongodb/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ inherits(CallbackStore, EventEmitter);
* @param {Object} [options] additional options for the collection.
*/
function Db(databaseName, serverConfig, options) {

if(!(this instanceof Db)) return new Db(databaseName, serverConfig, options);

EventEmitter.call(this);
this.databaseName = databaseName;
this.serverConfig = serverConfig;
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/gridfs/chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var BinaryParser = require('../bson/binary_parser').BinaryParser,
* @see Chunk#buildMongoObject
*/
var Chunk = exports.Chunk = function(file, mongoObject) {
if(!(this instanceof Chunk)) return new Chunk(file, mongoObject);

this.file = file;
var self = this;
var mongoObjectFinal = mongoObject == null ? {} : mongoObject;
Expand Down
3 changes: 3 additions & 0 deletions lib/mongodb/gridfs/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var GridStore = require('./gridstore').GridStore,
* @return {Grid}
*/
function Grid(db, fsName) {

if(!(this instanceof Grid)) return new Grid(db, fsName);

this.db = db;
this.fsName = fsName == null ? GridStore.DEFAULT_ROOT_COLLECTION : fsName;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/mongodb/gridfs/gridstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ var REFERENCE_BY_FILENAME = 0,
* @return {GridStore}
*/
function GridStore(db, fileIdObject, mode, options) {
if(!(this instanceof GridStore)) return new GridStore(db, fileIdObject, mode, options);

var self = this;
this.db = db;

Expand Down