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/lib/collection.js CHANGED
@@ -1,19 +1,17 @@
1
- module.exports = function init(____0, option, db) {
1
+ module.exports = function init(____0, options, db) {
2
2
  const $collection = {};
3
3
 
4
4
  ____0.on(____0.strings[4], (_) => {
5
- $collection.busy = !_;
5
+ $collection.taskBusy = !_;
6
6
  });
7
7
 
8
- if (typeof option === 'string') {
9
- option = {
10
- collection: option,
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, ...option };
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.opration_busy = !1;
35
- $collection.opration_list = [];
36
- $collection.run_count = 0;
31
+ $collection.taskBusy = !1;
32
+ $collection.taskList = [];
33
+ $collection.taskCount = 0;
37
34
 
38
- $collection.run = function () {
39
- $collection.run_count++;
40
- // console.log('run : ' + $collection.run_count + ' , count : ' + $collection.opration_list.length)
41
- if ($collection.opration_busy) {
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.opration_list.length == 0) {
44
+ if ($collection.taskList.length == 0) {
45
45
  return;
46
46
  }
47
- $collection.opration_busy = !0;
48
- let opration = $collection.opration_list.shift();
49
-
50
- if (opration.type == 'add') {
51
- $collection.add(opration.options, opration.callback, 2);
52
- } else if (opration.type == 'addAll') {
53
- $collection.addAll(opration.options, opration.callback, 2);
54
- } else if (opration.type == 'update') {
55
- $collection.update(opration.options, opration.callback, 2);
56
- } else if (opration.type == 'updateAll') {
57
- $collection.updateAll(opration.options, opration.callback, 2);
58
- } else if (opration.type == 'delete') {
59
- $collection.delete(opration.options, opration.callback, 2);
60
- } else if (opration.type == 'deleteAll') {
61
- $collection.deleteAll(opration.options, opration.callback, 2);
62
- } else if (opration.type == 'get') {
63
- $collection.get(opration.options, opration.callback, 2);
64
- } else if (opration.type == 'getAll') {
65
- $collection.getAll(opration.options, opration.callback, 2);
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, run) => {
74
- if ($collection.busy) {
75
- setTimeout(() => {
76
- $collection.add($doc, callback, run);
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: Object.assign({}, $doc),
105
+ doc: $doc,
112
106
  },
113
107
  function (err, docInserted) {
114
108
  callback(err, docInserted, $doc);
115
- if (run === !0) {
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, run) => {
129
- callback =
130
- callback ||
131
- function (...args) {
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 option = {};
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 (option.set) {
164
- delete option.set._id;
129
+ if (options.set) {
130
+ newOptions.set = options.set;
131
+ } else {
132
+ newOptions.set = options;
165
133
  }
166
134
 
167
- if (option.where === undefined || option.set === undefined) {
168
- callback({
169
- message: 'Must Assign [ Where & Set ] Properties',
170
- });
171
- if (run === !0) {
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 && typeof options.where === 'string') {
180
- options.where = {
181
- _id: $collection.ObjectId(options.where),
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 (options.where && options.where._id && typeof options.where._id === 'string') {
186
- options.where._id = $collection.ObjectId(options.where._id);
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 (options.where && options.where.id) {
190
- options.where.id = ____0.toInt(options.where.id);
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: option.where,
198
- set: option.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
- if (run === !0) {
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, run) => {
216
- callback = callback || function () {};
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 (run !== 2 && run !== !0) {
223
- $collection.opration_list.push({
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 options = {};
198
+ let newOptions = {};
231
199
 
232
200
  if ($options.where === undefined) {
233
- options.where = $options;
201
+ newOptions.where = $options;
234
202
  } else {
235
- options = $options;
203
+ newOptions = $options;
236
204
  }
237
205
 
238
- if (typeof options.where === 'string') {
239
- options.where = {
240
- _id: $collection.ObjectId(options.where),
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
- if (options.where && options.where._id && typeof options.where._id === 'string') {
245
- options.where._id = $collection.ObjectId(options.where._id);
211
+ $collection.taskBusy = !1;
212
+ return;
246
213
  }
247
214
 
248
- if (options.where && options.where.id) {
249
- options.where.id = ____0.toInt(options.where.id);
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: options.where,
223
+ where: newOptions.where,
260
224
  },
261
225
  function (err, result) {
262
226
  callback(err, result);
263
- if (run === !0) {
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, run) => {
279
- callback = callback || function () {};
280
- if (run !== 2 && run !== !0) {
281
- $collection.opration_list.push({
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
- if (options.where === undefined && options.select === undefined) {
289
- options = {
290
- where: { ...options },
291
- };
292
- }
247
+ let newOptions = {};
293
248
 
294
- if (options.where && typeof options.where === 'string') {
295
- options.where = {
296
- _id: $collection.ObjectId(options.where),
297
- };
249
+ if (options.where === undefined) {
250
+ newOptions.where = options;
251
+ } else {
252
+ newOptions.where = options.where;
298
253
  }
299
-
300
- if (options.where && options.where._id && typeof options.where._id === 'string') {
301
- options.where._id = $collection.ObjectId(options.where._id);
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 (options.where && options.where.id && typeof options.where.id === 'string') {
305
- options.where.id = ____0.toInt(options.where.id);
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: options.where || {},
313
- select: options.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
- if (run === !0) {
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, run) => {
333
- callback = callback || function () {};
334
- if (run !== 2 && run !== !0) {
335
- $collection.opration_list.push({
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
- options = { where: options };
332
+ newOptions.where = options;
344
333
  }
345
- if (options.where && typeof options.where === 'string') {
346
- options.where = {
347
- _id: $collection.ObjectId(options.where),
348
- };
334
+ if (options.where) {
335
+ newOptions.where = options.where;
349
336
  }
350
-
351
- if (options.where && options.where._id && typeof options.where._id === 'string') {
352
- options.where._id = $collection.ObjectId(options.where._id);
337
+ if (options.select) {
338
+ newOptions.select = options.select;
353
339
  }
354
-
355
- if (options.where && options.where.id && typeof options.where.id === 'string') {
356
- options.where.id = ____0.toInt(options.where.id);
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: options.where || {},
364
- select: options.select || {},
365
- limit: options.limit || ____0.options.mongodb.limit,
366
- sort: options.sort || null,
367
- skip: options.skip || 0,
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
- if (run === !0) {
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, run) => {
385
- callback = callback || function () {};
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 (run !== 2 && run !== !0) {
395
- $collection.opration_list.push({
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
- if (run === !0) {
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, run) => {
444
- callback = callback || function () {};
424
+ (options, callback, canRunTask = false) => {
425
+ callback = callback || $collection.callback;
445
426
 
446
- if (run !== 2 && run !== !0) {
447
- $collection.opration_list.push({
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
- if (options.where && options.where._id && typeof options.where._id === 'string') {
473
- options.where._id = $collection.ObjectId(options.where._id);
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
- if (run === !0) {
492
- return;
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, run) => {
505
- callback = callback || function () {};
506
- if (run !== 2 && run !== !0) {
507
- $collection.opration_list.push({
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 = { ...$options };
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
- if (run === !0) {
544
- return;
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 || function () {};
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 || function () {};
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.aggregate(
875
- [
876
- {
877
- $group: {
878
- _id: {
879
- id: '$id',
880
- },
881
- dups: {
882
- $push: '$_id',
883
- },
884
- count: {
885
- $sum: 1,
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
- $match: {
891
- count: {
892
- $gt: 1,
811
+ {
812
+ $match: {
813
+ count: {
814
+ $gt: 1,
815
+ },
893
816
  },
894
817
  },
895
- },
896
- ],
897
- function (err, docs) {
898
- if (!err && docs) {
899
- let arr = [];
900
- docs.forEach((doc) => {
901
- doc.dups.shift();
902
- doc.dups.forEach((dup) => {
903
- arr.push(dup);
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
- $collection.deleteAll(
907
- {
908
- _id: {
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
- return;
923
- }
924
- );
846
+ );
847
+ }
925
848
 
926
849
  $collection.handleIndex = function () {
927
- $collection.busy = !0;
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.busy = !1;
881
+ $collection.taskBusy = !1;
959
882
  }
960
883
  );
961
884
  };