Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_ref.js 719B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * A class representation of the BSON DBRef type.
  3. *
  4. * @class
  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. */
  10. function DBRef(namespace, oid, db) {
  11. if (!(this instanceof DBRef)) return new DBRef(namespace, oid, db);
  12. this._bsontype = 'DBRef';
  13. this.namespace = namespace;
  14. this.oid = oid;
  15. this.db = db;
  16. }
  17. /**
  18. * @ignore
  19. * @api private
  20. */
  21. DBRef.prototype.toJSON = function() {
  22. return {
  23. $ref: this.namespace,
  24. $id: this.oid,
  25. $db: this.db == null ? '' : this.db
  26. };
  27. };
  28. module.exports = DBRef;
  29. module.exports.DBRef = DBRef;