c2-mongoose 2.1.386 → 2.1.387
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.
|
@@ -37,6 +37,12 @@ var OneToManyFlowItem = /** @class */ (function () {
|
|
|
37
37
|
var model = mongoose_1.default.connection.models[Object.keys(mongoose_1.default.connection.models).find(function (key) { return mongoose_1.default.connection.models[key].collection.name === foreing.collectionChild; })];
|
|
38
38
|
console.info("finding", foreing.collectionChild);
|
|
39
39
|
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
|
+
}
|
|
40
46
|
if (model) {
|
|
41
47
|
var populates = populate.split(" ").filter(function (p) { return p.startsWith(labeled); });
|
|
42
48
|
console.info("iterate", populates);
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ class OneToManyFlowItem {
|
|
|
25
25
|
|
|
26
26
|
collection = [...collection, ...populateClauseLookup]
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
let model = mongoose.connection.models[
|
|
29
29
|
Object.keys(mongoose.connection.models).find(
|
|
30
30
|
key => mongoose.connection.models[key].collection.name === foreing.collectionChild
|
|
31
31
|
)!
|
|
@@ -33,6 +33,15 @@ class OneToManyFlowItem {
|
|
|
33
33
|
console.info("finding", foreing.collectionChild)
|
|
34
34
|
console.info("model", model)
|
|
35
35
|
|
|
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
|
+
|
|
36
45
|
if (model) {
|
|
37
46
|
const populates = populate.split(" ").filter((p: string) => p.startsWith(labeled))
|
|
38
47
|
|