isite 2024.9.1 → 2024.10.1
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/apps/client-side/site_files/css/bootstrap5-addon.css +3 -0
- package/apps/client-side/site_files/css/dropdown.css +1 -1
- package/apps/client-side/site_files/css/theme.css +1 -1
- package/apps/client-side/site_files/css/theme_dark.css +1 -1
- package/apps/client-side/site_files/css/theme_paper.css +1 -1
- package/apps/client-side/site_files/html/directive/i-list.html +1 -1
- package/apps/client-side/site_files/js/bootstrap-5-directive.js +8 -0
- package/apps/client-side/site_files/js/site.js +6 -2
- package/apps/client-side/site_files/js/site.min.js +1 -1
- package/apps/security/app.js +181 -175
- package/apps/security/site_files/js/login.js +33 -33
- package/index.js +16 -7
- package/lib/collection.js +266 -343
- package/lib/collectionFile.js +3 -2
- package/lib/dashboard.js +1 -1
- package/lib/mongodb.js +147 -206
- package/lib/parser.js +3 -0
- package/lib/routing.js +28 -12
- package/lib/security.js +10 -44
- package/lib/session.js +7 -6
- package/lib/sessions.js +49 -97
- package/lib/ws.js +38 -13
- package/lib/wsClient.js +7 -3
- package/object-options/index.js +2 -0
- package/object-options/lib/fn.js +28 -5
- package/package.json +2 -2
package/lib/collection.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
module.exports = function init(____0,
|
|
1
|
+
module.exports = function init(____0, options, db) {
|
|
2
2
|
const $collection = {};
|
|
3
3
|
|
|
4
4
|
____0.on(____0.strings[4], (_) => {
|
|
5
|
-
$collection.
|
|
5
|
+
$collection.taskBusy = !_;
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
if (typeof
|
|
9
|
-
|
|
10
|
-
collection:
|
|
8
|
+
if (typeof options === 'string') {
|
|
9
|
+
options = {
|
|
10
|
+
collection: options,
|
|
11
11
|
};
|
|
12
|
-
$collection.collection = option;
|
|
13
|
-
$collection.db = db || ____0.options.mongodb.db;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
$collection.options = { ...____0.options.mongodb, ...
|
|
14
|
+
$collection.options = { ...____0.options.mongodb, ...options };
|
|
17
15
|
$collection.options.db = $collection.options.db.trim().replace(' ', '');
|
|
18
16
|
$collection.options.collection = $collection.options.collection.trim().replace(' ', '');
|
|
19
17
|
$collection.identityEnabled = $collection.options.identity.enabled;
|
|
@@ -26,43 +24,49 @@ module.exports = function init(____0, option, db) {
|
|
|
26
24
|
$collection.collection = $collection.options.collection;
|
|
27
25
|
$collection.docs = [];
|
|
28
26
|
|
|
29
|
-
$collection.busy = !0;
|
|
30
27
|
$collection.insertBusy = !1;
|
|
31
28
|
$collection.updateBusy = !1;
|
|
32
29
|
$collection.deleteBusy = !1;
|
|
33
30
|
|
|
34
|
-
$collection.
|
|
35
|
-
$collection.
|
|
36
|
-
$collection.
|
|
31
|
+
$collection.taskBusy = !1;
|
|
32
|
+
$collection.taskList = [];
|
|
33
|
+
$collection.taskCount = 0;
|
|
37
34
|
|
|
38
|
-
$collection.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
$collection.callback = function (...args) {
|
|
36
|
+
console.log(...args);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
$collection.checkTaskList = function () {
|
|
40
|
+
// console.log('canRunTask : ' + $collection.taskCount + ' , count : ' + $collection.taskList.length)
|
|
41
|
+
if ($collection.taskBusy) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
if ($collection.
|
|
44
|
+
if ($collection.taskList.length == 0) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
$collection.
|
|
54
|
-
} else if (
|
|
55
|
-
$collection.
|
|
56
|
-
} else if (
|
|
57
|
-
$collection.
|
|
58
|
-
} else if (
|
|
59
|
-
$collection.
|
|
60
|
-
} else if (
|
|
61
|
-
$collection.
|
|
62
|
-
} else if (
|
|
63
|
-
$collection.
|
|
64
|
-
} else if (
|
|
65
|
-
$collection.
|
|
47
|
+
|
|
48
|
+
$collection.taskBusy = !0;
|
|
49
|
+
$collection.taskCount++;
|
|
50
|
+
let task = $collection.taskList.shift();
|
|
51
|
+
|
|
52
|
+
if (task.type == 'add') {
|
|
53
|
+
$collection.add(task.options, task.callback, true);
|
|
54
|
+
} else if (task.type == 'addAll') {
|
|
55
|
+
$collection.addAll(task.options, task.callback, true);
|
|
56
|
+
} else if (task.type == 'update') {
|
|
57
|
+
$collection.update(task.options, task.callback, true);
|
|
58
|
+
} else if (task.type == 'updateAll') {
|
|
59
|
+
$collection.updateAll(task.options, task.callback, true);
|
|
60
|
+
} else if (task.type == 'delete') {
|
|
61
|
+
$collection.delete(task.options, task.callback, true);
|
|
62
|
+
} else if (task.type == 'deleteAll') {
|
|
63
|
+
$collection.deleteAll(task.options, task.callback, true);
|
|
64
|
+
} else if (task.type == 'get') {
|
|
65
|
+
$collection.get(task.options, task.callback, true);
|
|
66
|
+
} else if (task.type == 'getAll') {
|
|
67
|
+
$collection.getAll(task.options, task.callback, true);
|
|
68
|
+
} else if (task.type == 'count') {
|
|
69
|
+
$collection.getCount(task.options, task.callback, true);
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
72
|
|
|
@@ -70,21 +74,14 @@ module.exports = function init(____0, option, db) {
|
|
|
70
74
|
$collection.insert =
|
|
71
75
|
$collection.add =
|
|
72
76
|
$collection.addOne =
|
|
73
|
-
($doc, callback,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, 100);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
callback = callback || function () {};
|
|
81
|
-
if (run !== 2 && run !== !0) {
|
|
82
|
-
$collection.opration_list.push({
|
|
77
|
+
($doc, callback, canRunTask = false) => {
|
|
78
|
+
callback = callback || $collection.callback;
|
|
79
|
+
if (!canRunTask) {
|
|
80
|
+
$collection.taskList.push({
|
|
83
81
|
options: $doc,
|
|
84
82
|
callback: callback,
|
|
85
83
|
type: 'add',
|
|
86
84
|
});
|
|
87
|
-
$collection.run();
|
|
88
85
|
} else {
|
|
89
86
|
$doc.id = typeof $doc.id === 'number' ? $doc.id : null;
|
|
90
87
|
|
|
@@ -100,23 +97,16 @@ module.exports = function init(____0, option, db) {
|
|
|
100
97
|
if ($collection.identityEnabled === !0 && $doc.id >= ____0.mongodb.collections_indexed[$collection.collection].nextID) {
|
|
101
98
|
____0.mongodb.collections_indexed[$collection.collection].nextID = $doc.id + 1;
|
|
102
99
|
}
|
|
103
|
-
if ($doc._id && typeof $doc._id === 'string') {
|
|
104
|
-
$doc._id = $collection.ObjectId($doc._id);
|
|
105
|
-
}
|
|
106
100
|
|
|
107
101
|
____0.mongodb.insertOne(
|
|
108
102
|
{
|
|
109
103
|
collectionName: $collection.collection,
|
|
110
104
|
dbName: $collection.db,
|
|
111
|
-
doc:
|
|
105
|
+
doc: $doc,
|
|
112
106
|
},
|
|
113
107
|
function (err, docInserted) {
|
|
114
108
|
callback(err, docInserted, $doc);
|
|
115
|
-
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
$collection.opration_busy = !1;
|
|
119
|
-
$collection.run();
|
|
109
|
+
$collection.taskBusy = !1;
|
|
120
110
|
}
|
|
121
111
|
);
|
|
122
112
|
}
|
|
@@ -125,85 +115,64 @@ module.exports = function init(____0, option, db) {
|
|
|
125
115
|
$collection.updateOne =
|
|
126
116
|
$collection.edit =
|
|
127
117
|
$collection.editOne =
|
|
128
|
-
(options, callback,
|
|
129
|
-
callback =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
console.log(args);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
if (!options) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (run !== 2 && run !== !0) {
|
|
139
|
-
$collection.opration_list.push({
|
|
118
|
+
(options, callback, canRunTask = false) => {
|
|
119
|
+
callback = callback || $collection.callback;
|
|
120
|
+
if (!canRunTask) {
|
|
121
|
+
$collection.taskList.push({
|
|
140
122
|
options: options,
|
|
141
123
|
callback: callback,
|
|
142
124
|
type: 'update',
|
|
143
125
|
});
|
|
144
|
-
$collection.run();
|
|
145
126
|
} else {
|
|
146
|
-
let
|
|
147
|
-
if (options._id) {
|
|
148
|
-
option.set = { ...options };
|
|
149
|
-
delete option.set._id;
|
|
150
|
-
option.where = {
|
|
151
|
-
_id: options._id,
|
|
152
|
-
};
|
|
153
|
-
} else if (options.id) {
|
|
154
|
-
option.set = { ...options };
|
|
155
|
-
delete option.set.id;
|
|
156
|
-
option.where = {
|
|
157
|
-
id: options.id,
|
|
158
|
-
};
|
|
159
|
-
} else if (options.set !== undefined) {
|
|
160
|
-
option = options;
|
|
161
|
-
}
|
|
127
|
+
let newOptions = {};
|
|
162
128
|
|
|
163
|
-
if (
|
|
164
|
-
|
|
129
|
+
if (options.set) {
|
|
130
|
+
newOptions.set = options.set;
|
|
131
|
+
} else {
|
|
132
|
+
newOptions.set = options;
|
|
165
133
|
}
|
|
166
134
|
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
$collection.opration_busy = !1;
|
|
175
|
-
$collection.run();
|
|
176
|
-
return;
|
|
135
|
+
if (options.unset) {
|
|
136
|
+
newOptions.unset = options.unset;
|
|
137
|
+
}
|
|
138
|
+
if (options.rename) {
|
|
139
|
+
newOptions.rename = options.rename;
|
|
177
140
|
}
|
|
178
141
|
|
|
179
|
-
if (options.where
|
|
180
|
-
|
|
181
|
-
|
|
142
|
+
if (options.where) {
|
|
143
|
+
newOptions.where = options.where;
|
|
144
|
+
} else {
|
|
145
|
+
newOptions.where = {
|
|
146
|
+
_id: newOptions.set._id,
|
|
147
|
+
id: newOptions.set.id,
|
|
182
148
|
};
|
|
183
149
|
}
|
|
184
150
|
|
|
185
|
-
if (
|
|
186
|
-
|
|
151
|
+
if (newOptions.where === undefined || newOptions.set === undefined) {
|
|
152
|
+
callback({
|
|
153
|
+
message: '\n updateOne() : Must Assign [ Where & Set ] Properties \n' + JSON.stringify(options),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
$collection.taskBusy = !1;
|
|
157
|
+
return;
|
|
187
158
|
}
|
|
188
159
|
|
|
189
|
-
if (
|
|
190
|
-
|
|
160
|
+
if (newOptions.where && newOptions.where.id) {
|
|
161
|
+
newOptions.where.id = ____0.toInt(newOptions.where.id);
|
|
191
162
|
}
|
|
192
163
|
|
|
193
164
|
____0.mongodb.updateOne(
|
|
194
165
|
{
|
|
195
166
|
collectionName: $collection.collection,
|
|
196
167
|
dbName: $collection.db,
|
|
197
|
-
where:
|
|
198
|
-
set:
|
|
168
|
+
where: newOptions.where,
|
|
169
|
+
set: newOptions.set || {},
|
|
170
|
+
unset: newOptions.unset || {},
|
|
171
|
+
rename: newOptions.rename || {},
|
|
199
172
|
},
|
|
200
173
|
function (err, result, result2) {
|
|
201
174
|
callback(err, result, result2);
|
|
202
|
-
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
$collection.opration_busy = !1;
|
|
206
|
-
$collection.run();
|
|
175
|
+
$collection.taskBusy = !1;
|
|
207
176
|
}
|
|
208
177
|
);
|
|
209
178
|
}
|
|
@@ -212,59 +181,50 @@ module.exports = function init(____0, option, db) {
|
|
|
212
181
|
$collection.deleteOne =
|
|
213
182
|
$collection.remove =
|
|
214
183
|
$collection.removeOne =
|
|
215
|
-
($options, callback,
|
|
216
|
-
callback = callback ||
|
|
184
|
+
($options, callback, canRunTask = false) => {
|
|
185
|
+
callback = callback || $collection.callback;
|
|
217
186
|
|
|
218
187
|
if (!$options) {
|
|
219
188
|
return;
|
|
220
189
|
}
|
|
221
190
|
|
|
222
|
-
if (
|
|
223
|
-
$collection.
|
|
191
|
+
if (!canRunTask) {
|
|
192
|
+
$collection.taskList.push({
|
|
224
193
|
options: $options,
|
|
225
194
|
callback: callback,
|
|
226
195
|
type: 'delete',
|
|
227
196
|
});
|
|
228
|
-
$collection.run();
|
|
229
197
|
} else {
|
|
230
|
-
let
|
|
198
|
+
let newOptions = {};
|
|
231
199
|
|
|
232
200
|
if ($options.where === undefined) {
|
|
233
|
-
|
|
201
|
+
newOptions.where = $options;
|
|
234
202
|
} else {
|
|
235
|
-
|
|
203
|
+
newOptions = $options;
|
|
236
204
|
}
|
|
237
205
|
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
}
|
|
206
|
+
if (newOptions.where === undefined) {
|
|
207
|
+
callback({
|
|
208
|
+
message: '\n delete() : Must Assign [ Where ] Propertie \n' + JSON.stringify(options),
|
|
209
|
+
});
|
|
243
210
|
|
|
244
|
-
|
|
245
|
-
|
|
211
|
+
$collection.taskBusy = !1;
|
|
212
|
+
return;
|
|
246
213
|
}
|
|
247
214
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
215
|
+
if (typeof newOptions.where.id === 'string') {
|
|
216
|
+
newOptions.where.id = ____0.toInt(newOptions.where.id);
|
|
250
217
|
}
|
|
251
218
|
|
|
252
|
-
delete options.where.$req;
|
|
253
|
-
delete options.where.$res;
|
|
254
|
-
|
|
255
219
|
____0.mongodb.deleteOne(
|
|
256
220
|
{
|
|
257
221
|
collectionName: $collection.collection,
|
|
258
222
|
dbName: $collection.db,
|
|
259
|
-
where:
|
|
223
|
+
where: newOptions.where,
|
|
260
224
|
},
|
|
261
225
|
function (err, result) {
|
|
262
226
|
callback(err, result);
|
|
263
|
-
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
$collection.opration_busy = !1;
|
|
267
|
-
$collection.run();
|
|
227
|
+
$collection.taskBusy = !1;
|
|
268
228
|
}
|
|
269
229
|
);
|
|
270
230
|
}
|
|
@@ -275,104 +235,134 @@ module.exports = function init(____0, option, db) {
|
|
|
275
235
|
$collection.findOne =
|
|
276
236
|
$collection.select =
|
|
277
237
|
$collection.selectOne =
|
|
278
|
-
(options, callback,
|
|
279
|
-
callback = callback ||
|
|
280
|
-
if (
|
|
281
|
-
$collection.
|
|
238
|
+
(options, callback, canRunTask = false) => {
|
|
239
|
+
callback = callback || $collection.callback;
|
|
240
|
+
if (!canRunTask) {
|
|
241
|
+
$collection.taskList.push({
|
|
282
242
|
options: options,
|
|
283
243
|
callback: callback,
|
|
284
244
|
type: 'get',
|
|
285
245
|
});
|
|
286
|
-
$collection.run();
|
|
287
246
|
} else {
|
|
288
|
-
|
|
289
|
-
options = {
|
|
290
|
-
where: { ...options },
|
|
291
|
-
};
|
|
292
|
-
}
|
|
247
|
+
let newOptions = {};
|
|
293
248
|
|
|
294
|
-
if (options.where
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
249
|
+
if (options.where === undefined) {
|
|
250
|
+
newOptions.where = options;
|
|
251
|
+
} else {
|
|
252
|
+
newOptions.where = options.where;
|
|
298
253
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
254
|
+
if (options.select === undefined) {
|
|
255
|
+
newOptions.select = {};
|
|
256
|
+
} else {
|
|
257
|
+
newOptions.select = options.select;
|
|
258
|
+
}
|
|
259
|
+
if (options.sort === undefined) {
|
|
260
|
+
newOptions.sort = {};
|
|
261
|
+
} else {
|
|
262
|
+
newOptions.sort = options.sort;
|
|
302
263
|
}
|
|
303
264
|
|
|
304
|
-
if (
|
|
305
|
-
|
|
265
|
+
if (newOptions.where.id && typeof newOptions.where.id === 'string') {
|
|
266
|
+
newOptions.where.id = ____0.toInt(newOptions.where.id);
|
|
306
267
|
}
|
|
307
268
|
|
|
308
269
|
____0.mongodb.findOne(
|
|
309
270
|
{
|
|
310
271
|
collectionName: $collection.collection,
|
|
311
272
|
dbName: $collection.db,
|
|
312
|
-
where:
|
|
313
|
-
select:
|
|
273
|
+
where: newOptions.where,
|
|
274
|
+
select: newOptions.select,
|
|
275
|
+
sort: newOptions.sort,
|
|
314
276
|
},
|
|
315
277
|
function (err, doc) {
|
|
316
278
|
callback(err, doc);
|
|
317
|
-
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
$collection.opration_busy = !1;
|
|
321
|
-
$collection.run();
|
|
279
|
+
$collection.taskBusy = !1;
|
|
322
280
|
}
|
|
323
281
|
);
|
|
324
282
|
}
|
|
325
283
|
};
|
|
284
|
+
$collection.count = $collection.getCount = function (options, callback, canRunTask = false) {
|
|
285
|
+
callback = callback || $collection.callback;
|
|
286
|
+
if (!canRunTask) {
|
|
287
|
+
$collection.taskList.push({
|
|
288
|
+
options: options,
|
|
289
|
+
callback: callback,
|
|
290
|
+
type: 'count',
|
|
291
|
+
});
|
|
292
|
+
} else {
|
|
293
|
+
let newOptions = { where: {} };
|
|
294
|
+
|
|
295
|
+
if (options.where) {
|
|
296
|
+
newOptions.where = options.where;
|
|
297
|
+
} else {
|
|
298
|
+
newOptions.where = options;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
____0.mongodb.count(
|
|
302
|
+
{
|
|
303
|
+
collectionName: $collection.collection,
|
|
304
|
+
dbName: $collection.db,
|
|
305
|
+
where: newOptions.where || {},
|
|
306
|
+
},
|
|
307
|
+
function (err, count) {
|
|
308
|
+
callback(err, count);
|
|
309
|
+
$collection.taskBusy = !1;
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
326
314
|
$collection.getMany =
|
|
327
315
|
$collection.getAll =
|
|
328
316
|
$collection.findAll =
|
|
329
317
|
$collection.findMany =
|
|
330
318
|
$collection.selectAll =
|
|
331
319
|
$collection.selectMany =
|
|
332
|
-
(options, callback,
|
|
333
|
-
callback = callback ||
|
|
334
|
-
if (
|
|
335
|
-
$collection.
|
|
320
|
+
(options, callback, canRunTask = false) => {
|
|
321
|
+
callback = callback || $collection.callback;
|
|
322
|
+
if (!canRunTask) {
|
|
323
|
+
$collection.taskList.push({
|
|
336
324
|
options: options,
|
|
337
325
|
callback: callback,
|
|
338
326
|
type: 'getAll',
|
|
339
327
|
});
|
|
340
|
-
$collection.run();
|
|
341
328
|
} else {
|
|
329
|
+
let newOptions = { where: {} };
|
|
330
|
+
|
|
342
331
|
if (!options.where && !options.select && !options.limit && !options.sort && !options.skip) {
|
|
343
|
-
|
|
332
|
+
newOptions.where = options;
|
|
344
333
|
}
|
|
345
|
-
if (options.where
|
|
346
|
-
|
|
347
|
-
_id: $collection.ObjectId(options.where),
|
|
348
|
-
};
|
|
334
|
+
if (options.where) {
|
|
335
|
+
newOptions.where = options.where;
|
|
349
336
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
options.where._id = $collection.ObjectId(options.where._id);
|
|
337
|
+
if (options.select) {
|
|
338
|
+
newOptions.select = options.select;
|
|
353
339
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
340
|
+
if (options.limit) {
|
|
341
|
+
newOptions.limit = options.limit;
|
|
342
|
+
}
|
|
343
|
+
if (options.sort) {
|
|
344
|
+
newOptions.sort = options.sort;
|
|
345
|
+
}
|
|
346
|
+
if (options.skip) {
|
|
347
|
+
newOptions.skip = options.skip;
|
|
348
|
+
}
|
|
349
|
+
if (newOptions.where.id && typeof newOptions.where.id === 'string') {
|
|
350
|
+
newOptions.where.id = ____0.toInt(newOptions.where.id);
|
|
357
351
|
}
|
|
358
352
|
|
|
359
353
|
____0.mongodb.findMany(
|
|
360
354
|
{
|
|
361
355
|
collectionName: $collection.collection,
|
|
362
356
|
dbName: $collection.db,
|
|
363
|
-
where:
|
|
364
|
-
select:
|
|
365
|
-
limit:
|
|
366
|
-
sort:
|
|
367
|
-
skip:
|
|
357
|
+
where: newOptions.where || {},
|
|
358
|
+
select: newOptions.select || {},
|
|
359
|
+
limit: newOptions.limit || ____0.options.mongodb.limit,
|
|
360
|
+
sort: newOptions.sort || null,
|
|
361
|
+
skip: newOptions.skip || 0,
|
|
368
362
|
},
|
|
369
363
|
function (err, docs, count) {
|
|
370
364
|
callback(err, docs, count);
|
|
371
|
-
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
$collection.opration_busy = !1;
|
|
375
|
-
$collection.run();
|
|
365
|
+
$collection.taskBusy = !1;
|
|
376
366
|
}
|
|
377
367
|
);
|
|
378
368
|
}
|
|
@@ -381,8 +371,8 @@ module.exports = function init(____0, option, db) {
|
|
|
381
371
|
$collection.addMany =
|
|
382
372
|
$collection.insertAll =
|
|
383
373
|
$collection.addAll =
|
|
384
|
-
(docs, callback,
|
|
385
|
-
callback = callback ||
|
|
374
|
+
(docs, callback, canRunTask = false) => {
|
|
375
|
+
callback = callback || $collection.callback;
|
|
386
376
|
|
|
387
377
|
if (!Array.isArray(docs) || docs.length === 0) {
|
|
388
378
|
callback({
|
|
@@ -391,20 +381,15 @@ module.exports = function init(____0, option, db) {
|
|
|
391
381
|
return;
|
|
392
382
|
}
|
|
393
383
|
|
|
394
|
-
if (
|
|
395
|
-
$collection.
|
|
384
|
+
if (!canRunTask) {
|
|
385
|
+
$collection.taskList.push({
|
|
396
386
|
options: docs,
|
|
397
387
|
callback: callback,
|
|
398
388
|
type: 'addAll',
|
|
399
389
|
});
|
|
400
|
-
$collection.run();
|
|
401
390
|
} else {
|
|
402
391
|
docs = docs.filter((d) => d !== null && typeof d == 'object');
|
|
403
392
|
docs.forEach(($doc) => {
|
|
404
|
-
if ($doc._id && typeof $doc._id === 'string') {
|
|
405
|
-
$doc._id = $collection.ObjectId($doc._id);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
393
|
if ($collection.identityEnabled === !0 && !$doc.id) {
|
|
409
394
|
$doc.id = ____0.mongodb.collections_indexed[$collection.collection].nextID;
|
|
410
395
|
____0.mongodb.collections_indexed[$collection.collection].nextID = $collection.step + ____0.mongodb.collections_indexed[$collection.collection].nextID;
|
|
@@ -427,11 +412,7 @@ module.exports = function init(____0, option, db) {
|
|
|
427
412
|
},
|
|
428
413
|
(err, result) => {
|
|
429
414
|
callback(err, result);
|
|
430
|
-
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
$collection.opration_busy = !1;
|
|
434
|
-
$collection.run();
|
|
415
|
+
$collection.taskBusy = !1;
|
|
435
416
|
}
|
|
436
417
|
);
|
|
437
418
|
}
|
|
@@ -440,37 +421,23 @@ module.exports = function init(____0, option, db) {
|
|
|
440
421
|
$collection.editMany =
|
|
441
422
|
$collection.updateAll =
|
|
442
423
|
$collection.editAll =
|
|
443
|
-
(options, callback,
|
|
444
|
-
callback = callback ||
|
|
424
|
+
(options, callback, canRunTask = false) => {
|
|
425
|
+
callback = callback || $collection.callback;
|
|
445
426
|
|
|
446
|
-
if (
|
|
447
|
-
$collection.
|
|
427
|
+
if (!canRunTask) {
|
|
428
|
+
$collection.taskList.push({
|
|
448
429
|
options: options,
|
|
449
430
|
callback: callback,
|
|
450
431
|
type: 'updateAll',
|
|
451
432
|
});
|
|
452
|
-
$collection.run();
|
|
453
433
|
} else {
|
|
454
434
|
if (options.where === undefined || options.set === undefined) {
|
|
455
435
|
callback({
|
|
456
|
-
message: 'Must Assign [ where , set ] Properties',
|
|
436
|
+
message: '\n updateMany() : Must Assign [ where , set ] Properties \n ' + JSON.stringify(options),
|
|
457
437
|
});
|
|
458
|
-
if (run === !0) {
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
$collection.opration_busy = !1;
|
|
462
|
-
$collection.run();
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (options.where && typeof options.where === 'string') {
|
|
467
|
-
options.where = {
|
|
468
|
-
_id: $collection.ObjectId(options.where),
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
438
|
|
|
472
|
-
|
|
473
|
-
|
|
439
|
+
$collection.taskBusy = !1;
|
|
440
|
+
return;
|
|
474
441
|
}
|
|
475
442
|
|
|
476
443
|
if (options.where && options.where.id && typeof options.where.id == 'string') {
|
|
@@ -488,11 +455,8 @@ module.exports = function init(____0, option, db) {
|
|
|
488
455
|
},
|
|
489
456
|
(err, result) => {
|
|
490
457
|
callback(err, result);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
$collection.opration_busy = !1;
|
|
495
|
-
$collection.run();
|
|
458
|
+
|
|
459
|
+
$collection.taskBusy = !1;
|
|
496
460
|
}
|
|
497
461
|
);
|
|
498
462
|
}
|
|
@@ -501,33 +465,22 @@ module.exports = function init(____0, option, db) {
|
|
|
501
465
|
$collection.removeMany =
|
|
502
466
|
$collection.deleteAll =
|
|
503
467
|
$collection.removeAll =
|
|
504
|
-
($options, callback,
|
|
505
|
-
callback = callback ||
|
|
506
|
-
if (
|
|
507
|
-
$collection.
|
|
468
|
+
($options, callback, canRunTask = false) => {
|
|
469
|
+
callback = callback || $collection.callback;
|
|
470
|
+
if (!canRunTask) {
|
|
471
|
+
$collection.taskList.push({
|
|
508
472
|
options: $options,
|
|
509
473
|
callback: callback,
|
|
510
474
|
type: 'deleteAll',
|
|
511
475
|
});
|
|
512
|
-
$collection.run();
|
|
513
476
|
} else {
|
|
514
477
|
let options = {};
|
|
515
478
|
if ($options.where === undefined) {
|
|
516
|
-
options.where =
|
|
479
|
+
options.where = $options;
|
|
517
480
|
} else {
|
|
518
481
|
options = $options;
|
|
519
482
|
}
|
|
520
483
|
|
|
521
|
-
if (typeof options.where === 'string') {
|
|
522
|
-
options.where = {
|
|
523
|
-
_id: $collection.ObjectId(options.where),
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (options.where._id && typeof options.where._id === 'string') {
|
|
528
|
-
options.where._id = $collection.ObjectId(options.where._id);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
484
|
if (options.where && options.where.id) {
|
|
532
485
|
options.where.id = ____0.toInt(options.where.id);
|
|
533
486
|
}
|
|
@@ -540,11 +493,8 @@ module.exports = function init(____0, option, db) {
|
|
|
540
493
|
},
|
|
541
494
|
function (err, result) {
|
|
542
495
|
callback(err, result);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
$collection.opration_busy = !1;
|
|
547
|
-
$collection.run();
|
|
496
|
+
|
|
497
|
+
$collection.taskBusy = !1;
|
|
548
498
|
}
|
|
549
499
|
);
|
|
550
500
|
}
|
|
@@ -558,11 +508,7 @@ module.exports = function init(____0, option, db) {
|
|
|
558
508
|
};
|
|
559
509
|
|
|
560
510
|
$collection.drop = (callback) => {
|
|
561
|
-
callback =
|
|
562
|
-
callback ||
|
|
563
|
-
function (...args) {
|
|
564
|
-
console.log(args);
|
|
565
|
-
};
|
|
511
|
+
callback = callback || $collection.callback;
|
|
566
512
|
____0.mongodb.dropCollection(
|
|
567
513
|
{
|
|
568
514
|
collectionName: $collection.collection,
|
|
@@ -578,11 +524,7 @@ module.exports = function init(____0, option, db) {
|
|
|
578
524
|
};
|
|
579
525
|
|
|
580
526
|
$collection.createUnique = (obj, callback) => {
|
|
581
|
-
callback =
|
|
582
|
-
callback ||
|
|
583
|
-
function (...args) {
|
|
584
|
-
console.log(args);
|
|
585
|
-
};
|
|
527
|
+
callback = callback || $collection.callback;
|
|
586
528
|
|
|
587
529
|
____0.mongodb.createIndex(
|
|
588
530
|
{
|
|
@@ -601,11 +543,7 @@ module.exports = function init(____0, option, db) {
|
|
|
601
543
|
};
|
|
602
544
|
|
|
603
545
|
$collection.createIndex = (obj, options, callback) => {
|
|
604
|
-
callback =
|
|
605
|
-
callback ||
|
|
606
|
-
function (...args) {
|
|
607
|
-
console.log(args);
|
|
608
|
-
};
|
|
546
|
+
callback = callback || $collection.callback;
|
|
609
547
|
|
|
610
548
|
if (typeof options == 'function') {
|
|
611
549
|
callback = options;
|
|
@@ -624,11 +562,7 @@ module.exports = function init(____0, option, db) {
|
|
|
624
562
|
);
|
|
625
563
|
};
|
|
626
564
|
$collection.dropIndex = (obj, options, callback) => {
|
|
627
|
-
callback =
|
|
628
|
-
callback ||
|
|
629
|
-
function (...args) {
|
|
630
|
-
console.log(args);
|
|
631
|
-
};
|
|
565
|
+
callback = callback || $collection.callback;
|
|
632
566
|
|
|
633
567
|
if (typeof options == 'function') {
|
|
634
568
|
callback = options;
|
|
@@ -647,11 +581,7 @@ module.exports = function init(____0, option, db) {
|
|
|
647
581
|
);
|
|
648
582
|
};
|
|
649
583
|
$collection.dropIndexes = (options, callback) => {
|
|
650
|
-
callback =
|
|
651
|
-
callback ||
|
|
652
|
-
function (...args) {
|
|
653
|
-
console.log(args);
|
|
654
|
-
};
|
|
584
|
+
callback = callback || $collection.callback;
|
|
655
585
|
|
|
656
586
|
if (typeof options == 'function') {
|
|
657
587
|
callback = options;
|
|
@@ -669,11 +599,7 @@ module.exports = function init(____0, option, db) {
|
|
|
669
599
|
);
|
|
670
600
|
};
|
|
671
601
|
$collection.aggregate = (arr, callback) => {
|
|
672
|
-
callback =
|
|
673
|
-
callback ||
|
|
674
|
-
function (...args) {
|
|
675
|
-
console.log(args);
|
|
676
|
-
};
|
|
602
|
+
callback = callback || $collection.callback;
|
|
677
603
|
|
|
678
604
|
____0.mongodb.aggregate(
|
|
679
605
|
{
|
|
@@ -688,11 +614,7 @@ module.exports = function init(____0, option, db) {
|
|
|
688
614
|
};
|
|
689
615
|
|
|
690
616
|
$collection.findDuplicate = (obj, callback) => {
|
|
691
|
-
callback =
|
|
692
|
-
callback ||
|
|
693
|
-
function (...args) {
|
|
694
|
-
console.log(args);
|
|
695
|
-
};
|
|
617
|
+
callback = callback || $collection.callback;
|
|
696
618
|
|
|
697
619
|
if (typeof obj === 'string') {
|
|
698
620
|
obj = {
|
|
@@ -741,11 +663,7 @@ module.exports = function init(____0, option, db) {
|
|
|
741
663
|
};
|
|
742
664
|
|
|
743
665
|
$collection.deleteDuplicate = $collection.removeDuplicate = (obj, callback) => {
|
|
744
|
-
callback =
|
|
745
|
-
callback ||
|
|
746
|
-
function (...args) {
|
|
747
|
-
console.log(args);
|
|
748
|
-
};
|
|
666
|
+
callback = callback || $collection.callback;
|
|
749
667
|
|
|
750
668
|
$collection.findDuplicate(obj, (err, result) => {
|
|
751
669
|
if (!err) {
|
|
@@ -783,11 +701,7 @@ module.exports = function init(____0, option, db) {
|
|
|
783
701
|
};
|
|
784
702
|
|
|
785
703
|
$collection.loadAll = (options, callback) => {
|
|
786
|
-
callback =
|
|
787
|
-
callback ||
|
|
788
|
-
function (...args) {
|
|
789
|
-
console.log(args);
|
|
790
|
-
};
|
|
704
|
+
callback = callback || $collection.callback;
|
|
791
705
|
|
|
792
706
|
____0.mongodb.findMany(
|
|
793
707
|
{
|
|
@@ -809,7 +723,7 @@ module.exports = function init(____0, option, db) {
|
|
|
809
723
|
};
|
|
810
724
|
|
|
811
725
|
$collection.import = function (file_path, callback) {
|
|
812
|
-
callback = callback ||
|
|
726
|
+
callback = callback || $collection.callback;
|
|
813
727
|
|
|
814
728
|
if (____0.isFileExistsSync(file_path)) {
|
|
815
729
|
console.log('[ imported file exists ]');
|
|
@@ -845,7 +759,7 @@ module.exports = function init(____0, option, db) {
|
|
|
845
759
|
};
|
|
846
760
|
|
|
847
761
|
$collection.export = function (options, file_path, callback) {
|
|
848
|
-
callback = callback ||
|
|
762
|
+
callback = callback || $collection.callback;
|
|
849
763
|
let response = {
|
|
850
764
|
done: !1,
|
|
851
765
|
file_path: file_path,
|
|
@@ -871,60 +785,69 @@ module.exports = function init(____0, option, db) {
|
|
|
871
785
|
// id Handle
|
|
872
786
|
|
|
873
787
|
if ($collection.identityEnabled) {
|
|
874
|
-
$collection.
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
788
|
+
$collection.createUnique(
|
|
789
|
+
{
|
|
790
|
+
id: 1,
|
|
791
|
+
},
|
|
792
|
+
() => {}
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
if ((deleteDuplicate = false)) {
|
|
796
|
+
$collection.aggregate(
|
|
797
|
+
[
|
|
798
|
+
{
|
|
799
|
+
$group: {
|
|
800
|
+
_id: {
|
|
801
|
+
id: '$id',
|
|
802
|
+
},
|
|
803
|
+
dups: {
|
|
804
|
+
$push: '$_id',
|
|
805
|
+
},
|
|
806
|
+
count: {
|
|
807
|
+
$sum: 1,
|
|
808
|
+
},
|
|
886
809
|
},
|
|
887
810
|
},
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
811
|
+
{
|
|
812
|
+
$match: {
|
|
813
|
+
count: {
|
|
814
|
+
$gt: 1,
|
|
815
|
+
},
|
|
893
816
|
},
|
|
894
817
|
},
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
818
|
+
],
|
|
819
|
+
function (err, docs) {
|
|
820
|
+
if (!err && docs) {
|
|
821
|
+
let arr = [];
|
|
822
|
+
docs.forEach((doc) => {
|
|
823
|
+
doc.dups.shift();
|
|
824
|
+
doc.dups.forEach((dup) => {
|
|
825
|
+
arr.push(dup);
|
|
826
|
+
});
|
|
904
827
|
});
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
$in: arr,
|
|
910
|
-
},
|
|
911
|
-
},
|
|
912
|
-
(err, result) => {
|
|
913
|
-
$collection.createUnique(
|
|
914
|
-
{
|
|
915
|
-
id: 1,
|
|
828
|
+
$collection.deleteAll(
|
|
829
|
+
{
|
|
830
|
+
_id: {
|
|
831
|
+
$in: arr,
|
|
916
832
|
},
|
|
917
|
-
|
|
918
|
-
)
|
|
919
|
-
|
|
920
|
-
|
|
833
|
+
},
|
|
834
|
+
(err, result) => {
|
|
835
|
+
$collection.createUnique(
|
|
836
|
+
{
|
|
837
|
+
id: 1,
|
|
838
|
+
},
|
|
839
|
+
() => {}
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
return;
|
|
921
845
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
);
|
|
846
|
+
);
|
|
847
|
+
}
|
|
925
848
|
|
|
926
849
|
$collection.handleIndex = function () {
|
|
927
|
-
$collection.
|
|
850
|
+
$collection.taskBusy = !0;
|
|
928
851
|
$collection.identityEnabled = !0;
|
|
929
852
|
$collection.step = ____0.options.mongodb.identity.step;
|
|
930
853
|
if (!____0.mongodb.collections_indexed[$collection.collection]) {
|
|
@@ -955,7 +878,7 @@ module.exports = function init(____0, option, db) {
|
|
|
955
878
|
}
|
|
956
879
|
|
|
957
880
|
____0.mongodb.collections_indexed[$collection.collection].nextID = id;
|
|
958
|
-
$collection.
|
|
881
|
+
$collection.taskBusy = !1;
|
|
959
882
|
}
|
|
960
883
|
);
|
|
961
884
|
};
|