drapi 1.8.48 → 1.8.49
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.
- package/lib/models.js +5 -3
- package/lib/router.js +2 -0
- package/package.json +1 -1
package/lib/models.js
CHANGED
|
@@ -27,7 +27,7 @@ let connectionschema = {};
|
|
|
27
27
|
|
|
28
28
|
let getConnection = function(dbname){
|
|
29
29
|
connectionschema[dbname] = connectionschema[dbname] || {};
|
|
30
|
-
let connection = db.getDatabaseConnection(dbname);
|
|
30
|
+
let connection = db.getDatabaseConnection(dbname);
|
|
31
31
|
return connection;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -49,6 +49,7 @@ let models = {
|
|
|
49
49
|
*/
|
|
50
50
|
getModelSchemaInstance: function(dbname, model, schema){
|
|
51
51
|
let connection = getConnection(dbname);
|
|
52
|
+
console.log("tamaño de la connection db antes de instancia model: ", dbname, model, sizeof(connection));
|
|
52
53
|
|
|
53
54
|
//Verify if the schema is allready initialized or if its atributos have changed
|
|
54
55
|
if(!connectionschema[dbname][model] || hasStructureChanged(connectionschema[dbname][model].obj, schema.attributes)){
|
|
@@ -67,8 +68,9 @@ let models = {
|
|
|
67
68
|
connectionschema[dbname][model] = modelSchema;
|
|
68
69
|
console.log("tamaño de schemas almacenados en memoria: ", sizeof(connectionschema));
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
let Model = connection.model(model, connectionschema[dbname][model]);
|
|
72
|
+
console.log("tamaño de la connection db despues de instancia model: ", dbname, model, sizeof(connection));
|
|
73
|
+
return Model;
|
|
72
74
|
},
|
|
73
75
|
/**
|
|
74
76
|
* Function incharge of initializing and returning dynamicaly a mongoose model
|
package/lib/router.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const Router = require('koa-router');
|
|
6
|
+
const sizeof = require('object-sizeof')
|
|
6
7
|
|
|
7
8
|
module.exports = function (pathToControllers, prefix, router){
|
|
8
9
|
var routerConf = prefix ? {prefix:prefix} : {};
|
|
@@ -23,5 +24,6 @@ module.exports = function (pathToControllers, prefix, router){
|
|
|
23
24
|
router.use(prefix, controller.router.routes(), controller.router.allowedMethods());
|
|
24
25
|
}
|
|
25
26
|
});
|
|
27
|
+
console.log("Tamaño de router ", sizeof(router));``
|
|
26
28
|
return router;
|
|
27
29
|
}
|