browser.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* eslint-env browser */
  2. 'use strict';
  3. require('./driver').set(require('./drivers/browser'));
  4. const DocumentProvider = require('./document_provider.js');
  5. const PromiseProvider = require('./promise_provider');
  6. DocumentProvider.setBrowser(true);
  7. /**
  8. * The Mongoose [Promise](#promise_Promise) constructor.
  9. *
  10. * @method Promise
  11. * @api public
  12. */
  13. Object.defineProperty(exports, 'Promise', {
  14. get: function() {
  15. return PromiseProvider.get();
  16. },
  17. set: function(lib) {
  18. PromiseProvider.set(lib);
  19. }
  20. });
  21. /**
  22. * Storage layer for mongoose promises
  23. *
  24. * @method PromiseProvider
  25. * @api public
  26. */
  27. exports.PromiseProvider = PromiseProvider;
  28. /**
  29. * The [MongooseError](#error_MongooseError) constructor.
  30. *
  31. * @method Error
  32. * @api public
  33. */
  34. exports.Error = require('./error');
  35. /**
  36. * The Mongoose [Schema](#schema_Schema) constructor
  37. *
  38. * ####Example:
  39. *
  40. * var mongoose = require('mongoose');
  41. * var Schema = mongoose.Schema;
  42. * var CatSchema = new Schema(..);
  43. *
  44. * @method Schema
  45. * @api public
  46. */
  47. exports.Schema = require('./schema');
  48. /**
  49. * The various Mongoose Types.
  50. *
  51. * ####Example:
  52. *
  53. * var mongoose = require('mongoose');
  54. * var array = mongoose.Types.Array;
  55. *
  56. * ####Types:
  57. *
  58. * - [ObjectId](#types-objectid-js)
  59. * - [Buffer](#types-buffer-js)
  60. * - [SubDocument](#types-embedded-js)
  61. * - [Array](#types-array-js)
  62. * - [DocumentArray](#types-documentarray-js)
  63. *
  64. * Using this exposed access to the `ObjectId` type, we can construct ids on demand.
  65. *
  66. * var ObjectId = mongoose.Types.ObjectId;
  67. * var id1 = new ObjectId;
  68. *
  69. * @property Types
  70. * @api public
  71. */
  72. exports.Types = require('./types');
  73. /**
  74. * The Mongoose [VirtualType](#virtualtype_VirtualType) constructor
  75. *
  76. * @method VirtualType
  77. * @api public
  78. */
  79. exports.VirtualType = require('./virtualtype');
  80. /**
  81. * The various Mongoose SchemaTypes.
  82. *
  83. * ####Note:
  84. *
  85. * _Alias of mongoose.Schema.Types for backwards compatibility._
  86. *
  87. * @property SchemaTypes
  88. * @see Schema.SchemaTypes #schema_Schema.Types
  89. * @api public
  90. */
  91. exports.SchemaType = require('./schematype.js');
  92. /**
  93. * Internal utils
  94. *
  95. * @property utils
  96. * @api private
  97. */
  98. exports.utils = require('./utils.js');
  99. /**
  100. * The Mongoose browser [Document](#document-js) constructor.
  101. *
  102. * @method Document
  103. * @api public
  104. */
  105. exports.Document = DocumentProvider();
  106. /**
  107. * function stub for model
  108. *
  109. * @method model
  110. * @api public
  111. * @return null
  112. */
  113. exports.model = function() {
  114. return null;
  115. };
  116. /*!
  117. * Module exports.
  118. */
  119. if (typeof window !== 'undefined') {
  120. window.mongoose = module.exports;
  121. window.Buffer = Buffer;
  122. }