drapi 1.8.46 → 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 CHANGED
@@ -7,6 +7,7 @@ const db = require('./db');
7
7
  const structure = require('../api/models/structure');
8
8
  const controllers = require('../api/models/model');
9
9
  const trigger = require('../api/models/trigger');
10
+ const sizeof = require('object-sizeof')
10
11
 
11
12
  /**
12
13
  * connectionschema = {
@@ -26,7 +27,7 @@ let connectionschema = {};
26
27
 
27
28
  let getConnection = function(dbname){
28
29
  connectionschema[dbname] = connectionschema[dbname] || {};
29
- let connection = db.getDatabaseConnection(dbname);
30
+ let connection = db.getDatabaseConnection(dbname);
30
31
  return connection;
31
32
  }
32
33
 
@@ -48,6 +49,7 @@ let models = {
48
49
  */
49
50
  getModelSchemaInstance: function(dbname, model, schema){
50
51
  let connection = getConnection(dbname);
52
+ console.log("tamaño de la connection db antes de instancia model: ", dbname, model, sizeof(connection));
51
53
 
52
54
  //Verify if the schema is allready initialized or if its atributos have changed
53
55
  if(!connectionschema[dbname][model] || hasStructureChanged(connectionschema[dbname][model].obj, schema.attributes)){
@@ -64,9 +66,11 @@ let models = {
64
66
  modelSchema.plugin(mongooseLogs, {schemaName:model,createAction:"Creó",updateAction:"Actualizó",deleteAction:"Eliminó"});
65
67
  // }
66
68
  connectionschema[dbname][model] = modelSchema;
69
+ console.log("tamaño de schemas almacenados en memoria: ", sizeof(connectionschema));
67
70
  }
68
-
69
- return connection.model(model, connectionschema[dbname][model]);
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;
70
74
  },
71
75
  /**
72
76
  * Function incharge of initializing and returning dynamicaly a mongoose model
@@ -81,11 +81,11 @@ class Permissions {
81
81
  }
82
82
  static async mergeWithPermissions(_query, _modelName, ctx) {
83
83
  //let query = JSON.parse(JSON.stringify(_query));
84
- let query = {};
84
+ let query = _query;
85
85
  let a = await this.getPermissions(_modelName, ctx);
86
86
  if (!this.avoidPermissions(a)) {
87
87
  let preparePemirssion = this.filterPermissionsInNotIn(a);
88
- _query = _.merge(_query, preparePemirssion);
88
+ query = _.merge(query, preparePemirssion);
89
89
  query = this.removeNullKeys(_query);
90
90
  }
91
91
  return query;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapi",
3
- "version": "1.8.46",
3
+ "version": "1.8.49",
4
4
  "description": "Dynamic rest api using mongoDb",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "mongoose": "^5.0.6",
22
22
  "mongoose-beautiful-unique-validation": "^7.1.1",
23
23
  "mongoose-delete": "^0.4.0",
24
+ "object-sizeof": "^1.6.3",
24
25
  "uuid": "^3.3.2"
25
26
  }
26
27
  }