PageRenderTime 34ms CodeModel.GetById 23ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/mongodb/node_modules/bson/lib/bson/db_ref.js

https://bitbucket.org/gagginaspinnata/todo-app-with-angularjs
JavaScript | 33 lines | 17 code | 3 blank | 13 comment | 3 complexity | ae5951f4a59467d96a091e41e342a1de MD5 | raw file
Possible License(s): Apache-2.0, MIT
 1/**
 2 * A class representation of the BSON DBRef type.
 3 *
 4 * @class Represents the BSON DBRef type.
 5 * @param {String} namespace the collection name.
 6 * @param {ObjectID} oid the reference ObjectID.
 7 * @param {String} [db] optional db name, if omitted the reference is local to the current db.
 8 * @return {DBRef}
 9 */
10function DBRef(namespace, oid, db) {
11  if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db);
12  
13  this._bsontype = 'DBRef';
14  this.namespace = namespace;
15  this.oid = oid;
16  this.db = db;
17};
18
19/**
20 * @ignore
21 * @api private
22 */
23DBRef.prototype.toJSON = function() {
24  return {
25    '$ref':this.namespace,
26    '$id':this.oid,
27    '$db':this.db == null ? '' : this.db
28  };
29}
30
31if(typeof window === 'undefined') {
32  exports.DBRef = DBRef;
33}