UNPKG

2.21 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var mongoose_1 = require("mongoose");
4exports.Model = mongoose_1.Model;
5exports.Schema = mongoose_1.Schema;
6var ModelFactory = /** @class */ (function () {
7 function ModelFactory(_config) {
8 this._config = _config;
9 }
10 Object.defineProperty(ModelFactory.prototype, "schema", {
11 get: function () {
12 if (!this._schema) {
13 var S = typeof this._config.mongooseInstance === 'function'
14 ? this._config.mongooseInstance().Schema
15 : this._config.mongooseInstance
16 ? this._config.mongooseInstance.Schema
17 : mongoose_1.Schema;
18 this._schema = new S(this._config.paths, this._config.options);
19 this._schema.method(this._config.methods || {});
20 this._schema.static(this._config.statics || {});
21 }
22 return this._schema;
23 },
24 enumerable: true,
25 configurable: true
26 });
27 Object.defineProperty(ModelFactory.prototype, "model", {
28 get: function () {
29 if (!this._model) {
30 var m = typeof this._config.mongooseInstance === 'function'
31 ? this._config.mongooseInstance().model
32 : this._config.mongooseInstance
33 ? this._config.mongooseInstance.model
34 : mongoose_1.model;
35 this._model = m(this._config.name, this.schema);
36 }
37 return this._model;
38 },
39 enumerable: true,
40 configurable: true
41 });
42 /**
43 * @deprecated Use <code>documentify<code> instead. This was a typo and will be removed in version 2.
44 */
45 ModelFactory.prototype.documetify = function (that) {
46 return this.documentify(that);
47 };
48 ModelFactory.prototype.documentify = function (that) {
49 return that;
50 };
51 ModelFactory.prototype.modelify = function (that) {
52 return that;
53 };
54 return ModelFactory;
55}());
56exports.ModelFactory = ModelFactory;
57//# sourceMappingURL=model-factory.js.map
\No newline at end of file