bonsaif 1.10.25 → 1.10.27

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/README.md CHANGED
@@ -1,201 +1,201 @@
1
- Eliminar publicacion
2
- npm unpublish bonsaif@1.9.23
3
-
4
-
5
- # [bonsaif.js](http://git.develsuit.com:6000/bonsaif/bonsaif-npm.git)
6
-
7
- bonsaif t is a library to connect to bonsaif apis
8
-
9
- ## Installation
10
-
11
- ```bash
12
- npm install bonsaif
13
- ```
14
-
15
- ## Examples
16
-
17
- Here is the first one to get you started:
18
-
19
- ```js
20
-
21
- const bonsaif = require('bonsaif');
22
- // utl,
23
- const {utl} = require('bonsaif');
24
-
25
- //ec
26
- const {ec} = require('bonsaif');
27
- const tag = "test";
28
-
29
- // ./cnf/endpoint.js
30
- const endpointMariaDB= {
31
- uri: '',
32
- user: '',
33
- password: '',
34
- client:'mariadb'
35
- };
36
-
37
- const localMariaDB= {
38
- uri:'',
39
- port: '',
40
- user:'',
41
- password:'',
42
- local:true,
43
- debug:false,
44
- client:'mariadb'
45
- };
46
-
47
- // Execute query
48
- const run =async()=>{
49
- //localhost
50
- let rs = await bonsaif.query({endpoint:localMariaDB, options:{db:'', sys:''}, query:'select * from table', tag});
51
- //endpoint
52
- let rs = await bonsaif.query({endpoint:endpointMariaDB, options:{db:'', sys:''}, query:'select * from table', tag});
53
- while (rs.next()){
54
- utl.log('row json',rs.row);
55
- let x = rs.row;
56
- utl.log('get field ['+x+']');
57
- utl.log('get field ['+rs.get('column')+']');
58
- utl.log('get field by Index ['+rs.get(0)+']');
59
- }
60
- }
61
- run();
62
- /**
63
- * Execute mongodb
64
- * https://www.mongodb.com/docs/manual/reference/command/
65
- **/
66
- const endpointMongo= {
67
- uri: '',
68
- user: '',
69
- password: '',
70
- client:'mongodb'
71
- };
72
-
73
- const localMongo= {
74
- uri:'',
75
- poolSize:8,
76
- local:true,
77
- debug:false,
78
- client:'mongodb'
79
- };
80
- const runMongo =async()=>{
81
-
82
- // localhost
83
- let insert = await bonsaif.query({endpoint:localMongo, options:{db:'', sys:''}, query:{insert: "collection", documents: [{ 'id':1, 'ds':'demo1' }]}, tag});
84
-
85
- //endpoint
86
- let insert = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{insert: "collection", documents: [{ 'id':1, 'ds':'demo1' }]}, tag});
87
- let find = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{find: "collection", filter: { 'id':1 }}, tag});
88
- let update = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{update: "collection", filter: { _id:1 } documents: [{ "id":1, "ds":"ds Change", "NewC":1 }]}, tag});
89
- let upsert = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{upsert: "collection", filter: { _id:1 }, document:{ 'id':1, 'ds':'ds1', 'live':0 } }, tag});
90
- }
91
-
92
- runMongo();
93
-
94
-
95
- /**
96
- * Execute redis
97
- * https://redis.io/commands/?group=set
98
- **/
99
- const endpointRedis= {
100
- uri: '',
101
- user: '',
102
- password: '',
103
- client:'redis'
104
- };
105
-
106
- const localRedis= {
107
- uri:'',
108
- local:true,
109
- debug:false,
110
- client:'redis'
111
- };
112
-
113
- const runRedis =async()=>{
114
- let redis;
115
-
116
- // localhost
117
- redis = await bonsaif.query({endpoint:localRedis, options:{db:'', sys:''} query:{set:"Key:Test", value:"123456"}, tag:'test'});
118
- utl.log('set ',redis);
119
-
120
- //endpoint
121
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Test", value:"123456"}, tag:'test'});
122
- utl.log('set ',redis);
123
-
124
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Expire", value:"123456", expire:20}, tag:'test'});
125
- utl.log('set expire ',redis);
126
-
127
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{get:"Key:Test"}, tag:'test'});
128
- utl.log('get ',redis);
129
-
130
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{scan:"log*"}, tag:'test'});
131
- utl.log('scan ',redis);
132
-
133
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{upsert:"log:test", value:{"id_":1, "ds":"ds", live:1, "child_id":2}, filter:{"id_":1}}, tag:'test'});
134
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{upsert:"log:test", value:{"id_":2, "ds":"ds2", live:1, "child_id":2}, filter:{"id_":2}}, tag:'test'});
135
- utl.log('upsert (sadd) ',redis);
136
-
137
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":"*"} }, tag:'test'});
138
- utl.log('hfind (smembers) ',redis);
139
-
140
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":"1"} }, tag:'test'});
141
- utl.log('hfind (smembers) ',redis);
142
-
143
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{$and:[{"id_":1},{"child_id":"2"}]},}, tag:'test'});
144
- utl.log('hfind (smembers) ',redis);
145
-
146
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{$or:[{"id_":1},{"child_id":"2"}]},}, tag:'test'});
147
- utl.log('hfind (smembers) ',redis);
148
-
149
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":{$in:[1,2]}}}, tag:'test'});
150
- utl.log('in (smembers) ',redis);
151
-
152
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Test:Del", value:"123456"}, tag:'test'});
153
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Key:Test:Del" }, tag:'test'});
154
- utl.log('del ',redis);
155
-
156
- //redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Total" }, tag:'test'});
157
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{incrby:"Total", value:1000, counter:1 }, tag:'test'});
158
- utl.log('incrby ',redis);
159
-
160
- //redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Total:Float" }, tag:'test'});
161
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{incrbyfloat:"Total:Float", value:1000.00, counter:-5.1 }, tag:'test'});
162
- utl.log('TotalFloat ',redis);
163
-
164
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"1" }, tag:'test'});
165
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"2" }, tag:'test'});
166
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"3" }, tag:'test'});
167
- utl.log('sadd ',redis);
168
-
169
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{smembers:"Member", "value":"2" }, tag:'test'});
170
- utl.log('smembers ',redis);
171
-
172
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{srem:"Member", "value":"2" }, tag:'test'});
173
- utl.log('srem ',redis);
174
-
175
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hset:"hset", "value":{"id_cli":"1000","username":"1","password": "2", "A":"1" } }, tag:'test'});
176
- utl.log('hset ',redis);
177
-
178
- redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hgetall:"hset"}, tag:'test'});
179
- utl.log('hgetall ',redis);
180
- }
181
-
182
- runRedis();
183
-
184
- utl.log('custom log '+utl.date()+' '+utl.hour());
185
-
186
- /**
187
- * Encript
188
- **/
189
-
190
- let key = ec.StringToHex('keyString');
191
- utl.log('['+ec.fromHexString(key)+']');
192
-
193
- let keyKP = ec.StringToHexKP('llave','keyStringKP');
194
- utl.log('['+ec.fromHexStringKP('llave',keyKP)+']');
195
-
196
-
197
- ```
198
-
199
-
200
- ## License
1
+ Eliminar publicacion
2
+ npm unpublish bonsaif@1.9.23
3
+
4
+
5
+ # [bonsaif.js](http://git.develsuit.com:6000/bonsaif/bonsaif-npm.git)
6
+
7
+ bonsaif t is a library to connect to bonsaif apis
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install bonsaif
13
+ ```
14
+
15
+ ## Examples
16
+
17
+ Here is the first one to get you started:
18
+
19
+ ```js
20
+
21
+ const bonsaif = require('bonsaif');
22
+ // utl,
23
+ const {utl} = require('bonsaif');
24
+
25
+ //ec
26
+ const {ec} = require('bonsaif');
27
+ const tag = "test";
28
+
29
+ // ./cnf/endpoint.js
30
+ const endpointMariaDB= {
31
+ uri: '',
32
+ user: '',
33
+ password: '',
34
+ client:'mariadb'
35
+ };
36
+
37
+ const localMariaDB= {
38
+ uri:'',
39
+ port: '',
40
+ user:'',
41
+ password:'',
42
+ local:true,
43
+ debug:false,
44
+ client:'mariadb'
45
+ };
46
+
47
+ // Execute query
48
+ const run =async()=>{
49
+ //localhost
50
+ let rs = await bonsaif.query({endpoint:localMariaDB, options:{db:'', sys:''}, query:'select * from table', tag});
51
+ //endpoint
52
+ let rs = await bonsaif.query({endpoint:endpointMariaDB, options:{db:'', sys:''}, query:'select * from table', tag});
53
+ while (rs.next()){
54
+ utl.log('row json',rs.row);
55
+ let x = rs.row;
56
+ utl.log('get field ['+x+']');
57
+ utl.log('get field ['+rs.get('column')+']');
58
+ utl.log('get field by Index ['+rs.get(0)+']');
59
+ }
60
+ }
61
+ run();
62
+ /**
63
+ * Execute mongodb
64
+ * https://www.mongodb.com/docs/manual/reference/command/
65
+ **/
66
+ const endpointMongo= {
67
+ uri: '',
68
+ user: '',
69
+ password: '',
70
+ client:'mongodb'
71
+ };
72
+
73
+ const localMongo= {
74
+ uri:'',
75
+ poolSize:8,
76
+ local:true,
77
+ debug:false,
78
+ client:'mongodb'
79
+ };
80
+ const runMongo =async()=>{
81
+
82
+ // localhost
83
+ let insert = await bonsaif.query({endpoint:localMongo, options:{db:'', sys:''}, query:{insert: "collection", documents: [{ 'id':1, 'ds':'demo1' }]}, tag});
84
+
85
+ //endpoint
86
+ let insert = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{insert: "collection", documents: [{ 'id':1, 'ds':'demo1' }]}, tag});
87
+ let find = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{find: "collection", filter: { 'id':1 }}, tag});
88
+ let update = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{update: "collection", filter: { _id:1 } documents: [{ "id":1, "ds":"ds Change", "NewC":1 }]}, tag});
89
+ let upsert = await bonsaif.query({endpoint:endpointMongo, options:{db:'', sys:''}, query:{upsert: "collection", filter: { _id:1 }, document:{ 'id':1, 'ds':'ds1', 'live':0 } }, tag});
90
+ }
91
+
92
+ runMongo();
93
+
94
+
95
+ /**
96
+ * Execute redis
97
+ * https://redis.io/commands/?group=set
98
+ **/
99
+ const endpointRedis= {
100
+ uri: '',
101
+ user: '',
102
+ password: '',
103
+ client:'redis'
104
+ };
105
+
106
+ const localRedis= {
107
+ uri:'',
108
+ local:true,
109
+ debug:false,
110
+ client:'redis'
111
+ };
112
+
113
+ const runRedis =async()=>{
114
+ let redis;
115
+
116
+ // localhost
117
+ redis = await bonsaif.query({endpoint:localRedis, options:{db:'', sys:''} query:{set:"Key:Test", value:"123456"}, tag:'test'});
118
+ utl.log('set ',redis);
119
+
120
+ //endpoint
121
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Test", value:"123456"}, tag:'test'});
122
+ utl.log('set ',redis);
123
+
124
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Expire", value:"123456", expire:20}, tag:'test'});
125
+ utl.log('set expire ',redis);
126
+
127
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{get:"Key:Test"}, tag:'test'});
128
+ utl.log('get ',redis);
129
+
130
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{scan:"log*"}, tag:'test'});
131
+ utl.log('scan ',redis);
132
+
133
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{upsert:"log:test", value:{"id_":1, "ds":"ds", live:1, "child_id":2}, filter:{"id_":1}}, tag:'test'});
134
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{upsert:"log:test", value:{"id_":2, "ds":"ds2", live:1, "child_id":2}, filter:{"id_":2}}, tag:'test'});
135
+ utl.log('upsert (sadd) ',redis);
136
+
137
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":"*"} }, tag:'test'});
138
+ utl.log('hfind (smembers) ',redis);
139
+
140
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":"1"} }, tag:'test'});
141
+ utl.log('hfind (smembers) ',redis);
142
+
143
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{$and:[{"id_":1},{"child_id":"2"}]},}, tag:'test'});
144
+ utl.log('hfind (smembers) ',redis);
145
+
146
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{$or:[{"id_":1},{"child_id":"2"}]},}, tag:'test'});
147
+ utl.log('hfind (smembers) ',redis);
148
+
149
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hfind:"log:test", filter:{"id_":{$in:[1,2]}}}, tag:'test'});
150
+ utl.log('in (smembers) ',redis);
151
+
152
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{set:"Key:Test:Del", value:"123456"}, tag:'test'});
153
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Key:Test:Del" }, tag:'test'});
154
+ utl.log('del ',redis);
155
+
156
+ //redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Total" }, tag:'test'});
157
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{incrby:"Total", value:1000, counter:1 }, tag:'test'});
158
+ utl.log('incrby ',redis);
159
+
160
+ //redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{del:"Total:Float" }, tag:'test'});
161
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{incrbyfloat:"Total:Float", value:1000.00, counter:-5.1 }, tag:'test'});
162
+ utl.log('TotalFloat ',redis);
163
+
164
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"1" }, tag:'test'});
165
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"2" }, tag:'test'});
166
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{sadd:"Member", "value":"3" }, tag:'test'});
167
+ utl.log('sadd ',redis);
168
+
169
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{smembers:"Member", "value":"2" }, tag:'test'});
170
+ utl.log('smembers ',redis);
171
+
172
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{srem:"Member", "value":"2" }, tag:'test'});
173
+ utl.log('srem ',redis);
174
+
175
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hset:"hset", "value":{"id_cli":"1000","username":"1","password": "2", "A":"1" } }, tag:'test'});
176
+ utl.log('hset ',redis);
177
+
178
+ redis = await bonsaif.query({endpoint:endpointRedis, options:{db:'1', sys:'cc2'}, query:{hgetall:"hset"}, tag:'test'});
179
+ utl.log('hgetall ',redis);
180
+ }
181
+
182
+ runRedis();
183
+
184
+ utl.log('custom log '+utl.date()+' '+utl.hour());
185
+
186
+ /**
187
+ * Encript
188
+ **/
189
+
190
+ let key = ec.StringToHex('keyString');
191
+ utl.log('['+ec.fromHexString(key)+']');
192
+
193
+ let keyKP = ec.StringToHexKP('llave','keyStringKP');
194
+ utl.log('['+ec.fromHexStringKP('llave',keyKP)+']');
195
+
196
+
197
+ ```
198
+
199
+
200
+ ## License
201
201
  [MIT](https://choosealicense.com/licenses/mit/)
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
- /**
2
- * ::: B[]NSAIF() ::: => 2022
3
- */
4
- 'use strict';
5
-
1
+ /**
2
+ * ::: B[]NSAIF() ::: => 2022
3
+ */
4
+ 'use strict';
5
+
6
6
  module.exports = require('./lib/bonsaif');
package/lib/bonsaif.js CHANGED
@@ -1,27 +1,27 @@
1
- /**
2
- * ::: B[]NSAIF() ::: => 2022
3
- */
4
-
5
- 'use strict';
6
-
7
- const utl = require('./utl');
8
- const execute = require('./execute');
9
- const ec = require('./ec');
10
- const network = require('./network');
11
-
12
- const query=(o)=>{
13
- return execute.query(o);
14
- }
15
-
16
- const backend=(o)=>{
17
- return execute.backend(o);
18
- }
19
-
20
- module.exports={
21
- utl,
22
- execute,
23
- query,
24
- backend,
25
- ec,
26
- network
1
+ /**
2
+ * ::: B[]NSAIF() ::: => 2022
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ const utl = require('./utl');
8
+ const execute = require('./execute');
9
+ const ec = require('./ec');
10
+ const network = require('./network');
11
+
12
+ const query=(o)=>{
13
+ return execute.query(o);
14
+ }
15
+
16
+ const backend=(o)=>{
17
+ return execute.backend(o);
18
+ }
19
+
20
+ module.exports={
21
+ utl,
22
+ execute,
23
+ query,
24
+ backend,
25
+ ec,
26
+ network
27
27
  }