c2-mongoose 2.1.387 → 2.1.389
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
var lodash_1 = require("lodash");
|
|
16
|
-
var mongoose_1 = __importDefault(require("mongoose"));
|
|
17
16
|
var LookupArrayFlowItem_1 = __importDefault(require("./LookupArrayFlowItem"));
|
|
18
17
|
var OneToManyFlowItem = /** @class */ (function () {
|
|
19
18
|
function OneToManyFlowItem() {
|
|
@@ -34,15 +33,14 @@ var OneToManyFlowItem = /** @class */ (function () {
|
|
|
34
33
|
},
|
|
35
34
|
];
|
|
36
35
|
collection = __spreadArray(__spreadArray([], collection, true), populateClauseLookup, true);
|
|
37
|
-
var model =
|
|
36
|
+
var model = global.connectionMongoose.model(foreing.collectionChild);
|
|
37
|
+
// let model = mongoose.connection.models[
|
|
38
|
+
// Object.keys(mongoose.connection.models).find(
|
|
39
|
+
// key => mongoose.connection.models[key].collection.name === foreing.collectionChild
|
|
40
|
+
// )!
|
|
41
|
+
// ];
|
|
38
42
|
console.info("finding", foreing.collectionChild);
|
|
39
43
|
console.info("model", model);
|
|
40
|
-
if (!model) {
|
|
41
|
-
// Cria um model genérico se não existir
|
|
42
|
-
model = mongoose_1.default.model((0, lodash_1.camelCase)(foreing.collectionChild), // nome do model
|
|
43
|
-
new mongoose_1.default.Schema({}, { strict: false }), foreing.collectionChild // nome da collection
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
44
|
if (model) {
|
|
47
45
|
var populates = populate.split(" ").filter(function (p) { return p.startsWith(labeled); });
|
|
48
46
|
console.info("iterate", populates);
|
package/package.json
CHANGED
|
@@ -25,23 +25,15 @@ class OneToManyFlowItem {
|
|
|
25
25
|
|
|
26
26
|
collection = [...collection, ...populateClauseLookup]
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const model = (global as any).connectionMongoose.model(foreing.collectionChild);
|
|
29
|
+
// let model = mongoose.connection.models[
|
|
30
|
+
// Object.keys(mongoose.connection.models).find(
|
|
31
|
+
// key => mongoose.connection.models[key].collection.name === foreing.collectionChild
|
|
32
|
+
// )!
|
|
33
|
+
// ];
|
|
33
34
|
console.info("finding", foreing.collectionChild)
|
|
34
35
|
console.info("model", model)
|
|
35
36
|
|
|
36
|
-
if (!model) {
|
|
37
|
-
// Cria um model genérico se não existir
|
|
38
|
-
model = mongoose.model(
|
|
39
|
-
camelCase(foreing.collectionChild), // nome do model
|
|
40
|
-
new mongoose.Schema({}, { strict: false }),
|
|
41
|
-
foreing.collectionChild // nome da collection
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
37
|
if (model) {
|
|
46
38
|
const populates = populate.split(" ").filter((p: string) => p.startsWith(labeled))
|
|
47
39
|
|