bonsaif 1.10.40 → 1.10.41

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/execute.js CHANGED
@@ -45,6 +45,7 @@ const query = async (o)=>{
45
45
  switch(o.endpoint.client){
46
46
  case 'mariadb': rs = await mariadb(o); break;
47
47
  case 'mongodb': rs = await mongodb(o); break;
48
+ case 'mongoose': rs = await mongoose(o); break;
48
49
  case 'redis': rs = await redis(o); break;
49
50
  case 'api': rs = await api(o); break;
50
51
  case 'postgres': rs = await postgres(o); break;
@@ -127,6 +128,44 @@ const mariadb= async(o)=>{
127
128
 
128
129
  /**
129
130
  *
131
+ * @param {object} o Configuracion de mongoose
132
+ * @returns
133
+ */
134
+ const mongoose= async(o)=>{
135
+ const { local=false } = o.endpoint;
136
+ const { db = '', resultFormat=true} = o.options;
137
+ o.options.dml = 'api';
138
+ o.body = o.query;
139
+
140
+ if (local){
141
+ try {
142
+ let mongoose = require("../lib/hookup/mongoose");
143
+ let r = await mongoose.api(o,db,o.body);
144
+ try{ r.query = o.query }catch(e){}
145
+ return resultFormat ? resultSet(r) : r ;
146
+ } catch (e) {
147
+ return {
148
+ result: {
149
+ error: 1,
150
+ code: 503,
151
+ msg: 'Mongoose no disponible: ' + e.message
152
+ },
153
+ data: []
154
+ };
155
+ }
156
+ }else{
157
+ return new Promise((resolve, reject)=>{
158
+ backend(o)
159
+ .then(r=>{
160
+ try{ r.query = o.query }catch(e){}
161
+ resolve(resultFormat ? resultSet(r) : r);
162
+ });
163
+ });
164
+ }
165
+ }
166
+
167
+ /**
168
+ *
130
169
  * @param {object} o Configuracion de redis
131
170
  * @returns
132
171
  */