1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var mongoose_1 = require("mongoose");
|
4 | exports.Model = mongoose_1.Model;
|
5 | exports.Schema = mongoose_1.Schema;
|
6 | var ModelFactory = (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 |
|
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 | }());
|
56 | exports.ModelFactory = ModelFactory;
|
57 |
|
\ | No newline at end of file |