@resolveio/server-lib 12.5.53 → 12.5.54
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/.nodemon.json +5 -0
- package/.vscode/settings.json +3 -0
- package/README.md +22 -0
- package/compileDTS.pl +64 -0
- package/gulpfile.js +127 -0
- package/mongodbensurers.js +2 -0
- package/mongostop.js +3 -0
- package/package.json +1 -1
- package/settings.development.json +13 -0
- package/src/client-server-app.ts +7 -0
- package/src/collections/app-status.collection.ts +51 -0
- package/src/collections/counter.collection.ts +54 -0
- package/src/collections/cron-job-history.collection.ts +82 -0
- package/src/collections/cron-job.collection.ts +85 -0
- package/src/collections/email-history.collection.ts +66 -0
- package/src/collections/email-verified.collection.ts +61 -0
- package/src/collections/file.collection.ts +73 -0
- package/src/collections/flag.collection.ts +56 -0
- package/src/collections/log-method-latency.collection.ts +64 -0
- package/src/collections/log-subscription.collection.ts +68 -0
- package/src/collections/log-ts.collection.ts +78 -0
- package/src/collections/log.collection.ts +77 -0
- package/src/collections/logged-in-users.collection.ts +65 -0
- package/src/collections/method-response.collection.ts +66 -0
- package/src/collections/monitor-cpu.collection.ts +63 -0
- package/src/collections/monitor-memory.collection.ts +75 -0
- package/src/collections/monitor-mongo.collection.ts +69 -0
- package/src/collections/notification.collection.ts +51 -0
- package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
- package/src/collections/report-builder-library.collection.ts +89 -0
- package/src/collections/report-builder-report.collection.ts +149 -0
- package/src/collections/user-group.collection.ts +90 -0
- package/src/collections/user-guide.collection.ts +57 -0
- package/src/collections/user.collection.ts +259 -0
- package/src/cron/cron.ts +188 -0
- package/src/fixtures/cron-jobs.ts +25 -0
- package/src/fixtures/init.ts +10 -0
- package/src/http/auth.ts +732 -0
- package/src/http/health.ts +7 -0
- package/src/http/home.ts +71 -0
- package/src/index.ts +71 -0
- package/src/managers/cron.manager.ts +208 -0
- package/src/managers/method.manager.ts +607 -0
- package/src/managers/mongo.manager.ts +2282 -0
- package/src/managers/monitor.manager.ts +323 -0
- package/src/managers/subscription.manager.ts +1196 -0
- package/{managers/subscription.performance.js → src/managers/subscription.performance.ts} +68 -33
- package/src/methods/accounts.ts +202 -0
- package/src/methods/aws.ts +507 -0
- package/src/methods/collections.ts +512 -0
- package/src/methods/counters.ts +75 -0
- package/src/methods/cron-jobs.ts +1454 -0
- package/src/methods/flags.ts +7 -0
- package/src/methods/logs.ts +327 -0
- package/src/methods/monitor.ts +548 -0
- package/src/methods/pdf.ts +615 -0
- package/src/methods/report-builder.ts +876 -0
- package/src/methods/support.ts +146 -0
- package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
- package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
- package/src/models/collection-document.model.ts +22 -0
- package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
- package/src/models/cron-job-history.model.ts +13 -0
- package/src/models/cron-job.model.ts +14 -0
- package/src/models/dialog.model.ts +25 -0
- package/{models/email-history.model.d.ts → src/models/email-history.model.ts} +8 -7
- package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
- package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
- package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
- package/{models/log-method-latency.model.d.ts → src/models/log-method-latency.model.ts} +5 -4
- package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +8 -6
- package/{models/log.model.d.ts → src/models/log.model.ts} +12 -10
- package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
- package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
- package/src/models/method.model.ts +11 -0
- package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
- package/src/models/monitor-memory.model.ts +17 -0
- package/src/models/monitor-mongo.model.ts +15 -0
- package/{models/notification.model.d.ts → src/models/notification.model.ts} +3 -2
- package/src/models/pagination.model.ts +30 -0
- package/src/models/permission.model.ts +14 -0
- package/src/models/report-builder-dashboard-builder.model.ts +29 -0
- package/src/models/report-builder-library.model.ts +20 -0
- package/src/models/report-builder-report.model.ts +110 -0
- package/src/models/report-builder.model.ts +68 -0
- package/src/models/select-data-label.model.ts +9 -0
- package/src/models/server-response.model.ts +5 -0
- package/src/models/subscription.model.ts +64 -0
- package/src/models/support-ticket.model.ts +81 -0
- package/src/models/user-group.model.ts +23 -0
- package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
- package/src/models/user.model.ts +79 -0
- package/{public_api.d.ts → src/public_api.ts} +1 -1
- package/src/publications/app-status.ts +13 -0
- package/src/publications/cron-jobs.ts +30 -0
- package/src/publications/files.ts +34 -0
- package/src/publications/flags.ts +20 -0
- package/src/publications/logs.ts +164 -0
- package/src/publications/method-responses.ts +13 -0
- package/src/publications/notifications.ts +13 -0
- package/src/publications/report-builder-dashboard-builders.ts +39 -0
- package/src/publications/report-builder-libraries.ts +41 -0
- package/src/publications/report-builder-reports.ts +48 -0
- package/src/publications/super-admin.ts +13 -0
- package/src/publications/user-groups.ts +12 -0
- package/src/publications/user-guides.ts +12 -0
- package/src/server-app.ts +769 -0
- package/src/util/common.ts +519 -0
- package/src/util/schema-report-builder.ts +413 -0
- package/tsconfig.json +30 -0
- package/tslint.json +143 -0
- package/client-server-app.d.ts +0 -1
- package/client-server-app.js +0 -48
- package/client-server-app.js.map +0 -1
- package/collections/app-status.collection.d.ts +0 -3
- package/collections/app-status.collection.js +0 -51
- package/collections/app-status.collection.js.map +0 -1
- package/collections/counter.collection.d.ts +0 -3
- package/collections/counter.collection.js +0 -54
- package/collections/counter.collection.js.map +0 -1
- package/collections/cron-job-history.collection.d.ts +0 -3
- package/collections/cron-job-history.collection.js +0 -82
- package/collections/cron-job-history.collection.js.map +0 -1
- package/collections/cron-job.collection.d.ts +0 -3
- package/collections/cron-job.collection.js +0 -85
- package/collections/cron-job.collection.js.map +0 -1
- package/collections/email-history.collection.d.ts +0 -3
- package/collections/email-history.collection.js +0 -66
- package/collections/email-history.collection.js.map +0 -1
- package/collections/email-verified.collection.d.ts +0 -3
- package/collections/email-verified.collection.js +0 -61
- package/collections/email-verified.collection.js.map +0 -1
- package/collections/file.collection.d.ts +0 -3
- package/collections/file.collection.js +0 -73
- package/collections/file.collection.js.map +0 -1
- package/collections/flag.collection.d.ts +0 -3
- package/collections/flag.collection.js +0 -56
- package/collections/flag.collection.js.map +0 -1
- package/collections/log-method-latency.collection.d.ts +0 -3
- package/collections/log-method-latency.collection.js +0 -64
- package/collections/log-method-latency.collection.js.map +0 -1
- package/collections/log-subscription.collection.d.ts +0 -3
- package/collections/log-subscription.collection.js +0 -68
- package/collections/log-subscription.collection.js.map +0 -1
- package/collections/log-ts.collection.d.ts +0 -3
- package/collections/log-ts.collection.js +0 -78
- package/collections/log-ts.collection.js.map +0 -1
- package/collections/log.collection.d.ts +0 -3
- package/collections/log.collection.js +0 -77
- package/collections/log.collection.js.map +0 -1
- package/collections/logged-in-users.collection.d.ts +0 -3
- package/collections/logged-in-users.collection.js +0 -65
- package/collections/logged-in-users.collection.js.map +0 -1
- package/collections/method-response.collection.d.ts +0 -3
- package/collections/method-response.collection.js +0 -66
- package/collections/method-response.collection.js.map +0 -1
- package/collections/monitor-cpu.collection.d.ts +0 -3
- package/collections/monitor-cpu.collection.js +0 -63
- package/collections/monitor-cpu.collection.js.map +0 -1
- package/collections/monitor-memory.collection.d.ts +0 -3
- package/collections/monitor-memory.collection.js +0 -75
- package/collections/monitor-memory.collection.js.map +0 -1
- package/collections/monitor-mongo.collection.d.ts +0 -3
- package/collections/monitor-mongo.collection.js +0 -69
- package/collections/monitor-mongo.collection.js.map +0 -1
- package/collections/notification.collection.d.ts +0 -3
- package/collections/notification.collection.js +0 -51
- package/collections/notification.collection.js.map +0 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
- package/collections/report-builder-dashboard-builder.collection.js +0 -109
- package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
- package/collections/report-builder-library.collection.d.ts +0 -3
- package/collections/report-builder-library.collection.js +0 -87
- package/collections/report-builder-library.collection.js.map +0 -1
- package/collections/report-builder-report.collection.d.ts +0 -4
- package/collections/report-builder-report.collection.js +0 -149
- package/collections/report-builder-report.collection.js.map +0 -1
- package/collections/user-group.collection.d.ts +0 -4
- package/collections/user-group.collection.js +0 -90
- package/collections/user-group.collection.js.map +0 -1
- package/collections/user-guide.collection.d.ts +0 -3
- package/collections/user-guide.collection.js +0 -57
- package/collections/user-guide.collection.js.map +0 -1
- package/collections/user.collection.d.ts +0 -4
- package/collections/user.collection.js +0 -259
- package/collections/user.collection.js.map +0 -1
- package/cron/cron.d.ts +0 -5
- package/cron/cron.js +0 -162
- package/cron/cron.js.map +0 -1
- package/fixtures/cron-jobs.d.ts +0 -1
- package/fixtures/cron-jobs.js +0 -73
- package/fixtures/cron-jobs.js.map +0 -1
- package/fixtures/init.d.ts +0 -1
- package/fixtures/init.js +0 -59
- package/fixtures/init.js.map +0 -1
- package/http/auth.d.ts +0 -2
- package/http/auth.js +0 -763
- package/http/auth.js.map +0 -1
- package/http/health.d.ts +0 -1
- package/http/health.js +0 -12
- package/http/health.js.map +0 -1
- package/http/home.d.ts +0 -2
- package/http/home.js +0 -66
- package/http/home.js.map +0 -1
- package/index.d.ts +0 -23
- package/index.js +0 -127
- package/index.js.map +0 -1
- package/managers/cron.manager.d.ts +0 -17
- package/managers/cron.manager.js +0 -242
- package/managers/cron.manager.js.map +0 -1
- package/managers/method.manager.d.ts +0 -38
- package/managers/method.manager.js +0 -595
- package/managers/method.manager.js.map +0 -1
- package/managers/mongo.manager.d.ts +0 -178
- package/managers/mongo.manager.js +0 -2221
- package/managers/mongo.manager.js.map +0 -1
- package/managers/monitor.manager.d.ts +0 -59
- package/managers/monitor.manager.js +0 -351
- package/managers/monitor.manager.js.map +0 -1
- package/managers/subscription.manager.d.ts +0 -50
- package/managers/subscription.manager.js +0 -1091
- package/managers/subscription.manager.js.map +0 -1
- package/managers/subscription.performance.d.ts +0 -1
- package/managers/subscription.performance.js.map +0 -1
- package/methods/accounts.d.ts +0 -2
- package/methods/accounts.js +0 -274
- package/methods/accounts.js.map +0 -1
- package/methods/aws.d.ts +0 -2
- package/methods/aws.js +0 -617
- package/methods/aws.js.map +0 -1
- package/methods/collections.d.ts +0 -2
- package/methods/collections.js +0 -499
- package/methods/collections.js.map +0 -1
- package/methods/counters.d.ts +0 -2
- package/methods/counters.js +0 -122
- package/methods/counters.js.map +0 -1
- package/methods/cron-jobs.d.ts +0 -2
- package/methods/cron-jobs.js +0 -1315
- package/methods/cron-jobs.js.map +0 -1
- package/methods/flags.d.ts +0 -2
- package/methods/flags.js +0 -9
- package/methods/flags.js.map +0 -1
- package/methods/logs.d.ts +0 -2
- package/methods/logs.js +0 -371
- package/methods/logs.js.map +0 -1
- package/methods/monitor.d.ts +0 -2
- package/methods/monitor.js +0 -565
- package/methods/monitor.js.map +0 -1
- package/methods/pdf.d.ts +0 -2
- package/methods/pdf.js +0 -468
- package/methods/pdf.js.map +0 -1
- package/methods/report-builder.d.ts +0 -2
- package/methods/report-builder.js +0 -858
- package/methods/report-builder.js.map +0 -1
- package/methods/support.d.ts +0 -2
- package/methods/support.js +0 -246
- package/methods/support.js.map +0 -1
- package/models/app-status.model.js +0 -4
- package/models/app-status.model.js.map +0 -1
- package/models/billing-logged-in-users.model.js +0 -4
- package/models/billing-logged-in-users.model.js.map +0 -1
- package/models/collection-document.model.d.ts +0 -19
- package/models/collection-document.model.js +0 -4
- package/models/collection-document.model.js.map +0 -1
- package/models/counter.model.js +0 -4
- package/models/counter.model.js.map +0 -1
- package/models/cron-job-history.model.d.ts +0 -12
- package/models/cron-job-history.model.js +0 -4
- package/models/cron-job-history.model.js.map +0 -1
- package/models/cron-job.model.d.ts +0 -13
- package/models/cron-job.model.js +0 -4
- package/models/cron-job.model.js.map +0 -1
- package/models/dialog.model.d.ts +0 -23
- package/models/dialog.model.js +0 -4
- package/models/dialog.model.js.map +0 -1
- package/models/email-history.model.js +0 -4
- package/models/email-history.model.js.map +0 -1
- package/models/email-verified.model.js +0 -4
- package/models/email-verified.model.js.map +0 -1
- package/models/file.model.js +0 -4
- package/models/file.model.js.map +0 -1
- package/models/flag.model.js +0 -4
- package/models/flag.model.js.map +0 -1
- package/models/log-method-latency.model.js +0 -4
- package/models/log-method-latency.model.js.map +0 -1
- package/models/log-subscription.model.js +0 -4
- package/models/log-subscription.model.js.map +0 -1
- package/models/log.model.js +0 -4
- package/models/log.model.js.map +0 -1
- package/models/logged-in-users.model.js +0 -4
- package/models/logged-in-users.model.js.map +0 -1
- package/models/method-response.model.js +0 -4
- package/models/method-response.model.js.map +0 -1
- package/models/method.model.d.ts +0 -9
- package/models/method.model.js +0 -4
- package/models/method.model.js.map +0 -1
- package/models/monitor-cpu.model.js +0 -4
- package/models/monitor-cpu.model.js.map +0 -1
- package/models/monitor-memory.model.d.ts +0 -15
- package/models/monitor-memory.model.js +0 -4
- package/models/monitor-memory.model.js.map +0 -1
- package/models/monitor-mongo.model.d.ts +0 -13
- package/models/monitor-mongo.model.js +0 -4
- package/models/monitor-mongo.model.js.map +0 -1
- package/models/notification.model.js +0 -4
- package/models/notification.model.js.map +0 -1
- package/models/pagination.model.d.ts +0 -10
- package/models/pagination.model.js +0 -24
- package/models/pagination.model.js.map +0 -1
- package/models/permission.model.d.ts +0 -12
- package/models/permission.model.js +0 -4
- package/models/permission.model.js.map +0 -1
- package/models/report-builder-dashboard-builder.model.d.ts +0 -25
- package/models/report-builder-dashboard-builder.model.js +0 -4
- package/models/report-builder-dashboard-builder.model.js.map +0 -1
- package/models/report-builder-library.model.d.ts +0 -17
- package/models/report-builder-library.model.js +0 -4
- package/models/report-builder-library.model.js.map +0 -1
- package/models/report-builder-report.model.d.ts +0 -98
- package/models/report-builder-report.model.js +0 -4
- package/models/report-builder-report.model.js.map +0 -1
- package/models/report-builder.model.d.ts +0 -61
- package/models/report-builder.model.js +0 -4
- package/models/report-builder.model.js.map +0 -1
- package/models/select-data-label.model.d.ts +0 -9
- package/models/select-data-label.model.js +0 -4
- package/models/select-data-label.model.js.map +0 -1
- package/models/server-response.model.d.ts +0 -5
- package/models/server-response.model.js +0 -4
- package/models/server-response.model.js.map +0 -1
- package/models/subscription.model.d.ts +0 -23
- package/models/subscription.model.js +0 -4
- package/models/subscription.model.js.map +0 -1
- package/models/support-ticket.model.d.ts +0 -72
- package/models/support-ticket.model.js +0 -4
- package/models/support-ticket.model.js.map +0 -1
- package/models/user-group.model.d.ts +0 -19
- package/models/user-group.model.js +0 -4
- package/models/user-group.model.js.map +0 -1
- package/models/user-guide.model.js +0 -4
- package/models/user-guide.model.js.map +0 -1
- package/models/user.model.d.ts +0 -70
- package/models/user.model.js +0 -4
- package/models/user.model.js.map +0 -1
- package/public_api.js +0 -75
- package/public_api.js.map +0 -1
- package/publications/app-status.d.ts +0 -2
- package/publications/app-status.js +0 -17
- package/publications/app-status.js.map +0 -1
- package/publications/cron-jobs.d.ts +0 -2
- package/publications/cron-jobs.js +0 -33
- package/publications/cron-jobs.js.map +0 -1
- package/publications/files.d.ts +0 -2
- package/publications/files.js +0 -37
- package/publications/files.js.map +0 -1
- package/publications/flags.d.ts +0 -2
- package/publications/flags.js +0 -23
- package/publications/flags.js.map +0 -1
- package/publications/logs.d.ts +0 -2
- package/publications/logs.js +0 -165
- package/publications/logs.js.map +0 -1
- package/publications/method-responses.d.ts +0 -2
- package/publications/method-responses.js +0 -17
- package/publications/method-responses.js.map +0 -1
- package/publications/notifications.d.ts +0 -2
- package/publications/notifications.js +0 -17
- package/publications/notifications.js.map +0 -1
- package/publications/report-builder-dashboard-builders.d.ts +0 -2
- package/publications/report-builder-dashboard-builders.js +0 -43
- package/publications/report-builder-dashboard-builders.js.map +0 -1
- package/publications/report-builder-libraries.d.ts +0 -2
- package/publications/report-builder-libraries.js +0 -90
- package/publications/report-builder-libraries.js.map +0 -1
- package/publications/report-builder-reports.d.ts +0 -2
- package/publications/report-builder-reports.js +0 -51
- package/publications/report-builder-reports.js.map +0 -1
- package/publications/super-admin.d.ts +0 -2
- package/publications/super-admin.js +0 -17
- package/publications/super-admin.js.map +0 -1
- package/publications/user-groups.d.ts +0 -1
- package/publications/user-groups.js +0 -17
- package/publications/user-groups.js.map +0 -1
- package/publications/user-guides.d.ts +0 -1
- package/publications/user-guides.js +0 -17
- package/publications/user-guides.js.map +0 -1
- package/server-app.d.ts +0 -52
- package/server-app.js +0 -739
- package/server-app.js.map +0 -1
- package/util/common.d.ts +0 -24
- package/util/common.js +0 -511
- package/util/common.js.map +0 -1
- package/util/schema-report-builder.d.ts +0 -6
- package/util/schema-report-builder.js +0 -453
- package/util/schema-report-builder.js.map +0 -1
- /package/{private → src/private}/email-templates/enrollment.html +0 -0
- /package/{private → src/private}/email-templates/forgot-password.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket.html +0 -0
- /package/{private → src/private}/images/ResolveIO.png +0 -0
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { MethodManager } from '../managers/method.manager';
|
|
2
|
+
import { deepCopy, getMongoMergeUpdatedDoc } from '../util/common';
|
|
3
|
+
import SimpleSchema from 'simpl-schema';
|
|
4
|
+
import { PaginationOptionsSchema, PaginationOptions } from '../models/pagination.model';
|
|
5
|
+
import { ResolveIOServer } from '../index';
|
|
6
|
+
import { objectIdHexString } from '../managers/mongo.manager';
|
|
7
|
+
|
|
8
|
+
export function loadCollectionMethods(methodManager: MethodManager) {
|
|
9
|
+
methodManager.methods({
|
|
10
|
+
collectionListAll: {
|
|
11
|
+
function: function() {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
resolve(ResolveIOServer.getMongoManager().collections().map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
collectionListRB: {
|
|
18
|
+
function: function() {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
resolve(ResolveIOServer.getMongoManager().collections().filter(a => a.useRB).map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
// Query database for any collection and query
|
|
25
|
+
findOne: {
|
|
26
|
+
check: new SimpleSchema({
|
|
27
|
+
collection: {
|
|
28
|
+
type: String
|
|
29
|
+
},
|
|
30
|
+
query: {
|
|
31
|
+
type: Object,
|
|
32
|
+
blackbox: true
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
function: function(collection: string, query = {}) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
38
|
+
reject('Invalid collection');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
ResolveIOServer.getMongoManager().collection(collection).findOne(query).then(res => resolve(res), err => reject(err));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
find: {
|
|
47
|
+
check: new SimpleSchema({
|
|
48
|
+
collection: {
|
|
49
|
+
type: String
|
|
50
|
+
},
|
|
51
|
+
query: {
|
|
52
|
+
type: Object,
|
|
53
|
+
blackbox: true
|
|
54
|
+
},
|
|
55
|
+
sort: {
|
|
56
|
+
type: Object,
|
|
57
|
+
blackbox: true,
|
|
58
|
+
optional: true
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
function: function(collection: string, query = {}, sortQuery = {}) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
64
|
+
reject('Invalid collection');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
ResolveIOServer.getMongoManager().collection(collection).find(query, {sort: sortQuery}).then(res => resolve(res), err => reject(err));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
findWithOptions: {
|
|
73
|
+
check: new SimpleSchema({
|
|
74
|
+
collection: {
|
|
75
|
+
type: String
|
|
76
|
+
},
|
|
77
|
+
query: {
|
|
78
|
+
type: Object,
|
|
79
|
+
blackbox: true
|
|
80
|
+
},
|
|
81
|
+
options: {
|
|
82
|
+
type: PaginationOptionsSchema
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
function: function(collection: string, query: Object, options: PaginationOptions) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
88
|
+
reject('Invalid collection');
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
let optionsQuery = {};
|
|
92
|
+
|
|
93
|
+
if (options.fields && Object.keys(options.fields).length) {
|
|
94
|
+
optionsQuery['projection'] = options.fields;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (options.sort && Object.keys(options.sort).length) {
|
|
98
|
+
optionsQuery['sort'] = options.sort;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (options.limit) {
|
|
102
|
+
optionsQuery['limit'] = options.limit;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (options.skip) {
|
|
106
|
+
optionsQuery['skip'] = options.skip;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery).then(res => resolve(res), err => reject(err));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// Insert 1 document
|
|
115
|
+
// @Inputs: collection, document
|
|
116
|
+
// @Outputs: res = _id of new document, err = not inserted
|
|
117
|
+
insertDocument: {
|
|
118
|
+
check: new SimpleSchema({
|
|
119
|
+
collection: {
|
|
120
|
+
type: String
|
|
121
|
+
},
|
|
122
|
+
document: {
|
|
123
|
+
type: Object,
|
|
124
|
+
blackbox: true
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
function: function(collection: string, document: Object) {
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
130
|
+
reject('Invalid collection');
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
let id = objectIdHexString();
|
|
134
|
+
document['_id'] = id;
|
|
135
|
+
document['__v'] = 0;
|
|
136
|
+
|
|
137
|
+
ResolveIOServer.getMongoManager().collection(collection).insertOne(document).then(() => resolve(id), err => reject(err));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
// Insert 1 document
|
|
143
|
+
// @Inputs: collection, document
|
|
144
|
+
// @Outputs: res = _id of new document, err = not inserted
|
|
145
|
+
insertManyDocuments: {
|
|
146
|
+
check: new SimpleSchema({
|
|
147
|
+
collection: {
|
|
148
|
+
type: String
|
|
149
|
+
},
|
|
150
|
+
documents: {
|
|
151
|
+
type: Array
|
|
152
|
+
},
|
|
153
|
+
'documents.$': {
|
|
154
|
+
type: Object,
|
|
155
|
+
blackbox: true
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
function: function(collection: string, documents: Object[]) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
161
|
+
reject('Invalid collection');
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
documents.forEach(document => {
|
|
165
|
+
document['_id'] = objectIdHexString();
|
|
166
|
+
document['__v'] = 0;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
ResolveIOServer.getMongoManager().collection(collection).insertMany(documents).then(() => resolve(documents.map(a => a['_id'])), err => reject(err));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
// Replaces 1 document with new document (from _id)
|
|
175
|
+
// @Inputs: collection, document id
|
|
176
|
+
// @Outputs: res = 1 (updated 1), err = not updated/wrong version
|
|
177
|
+
// Search for doc, check version, if found then try and update
|
|
178
|
+
updateDocument: {
|
|
179
|
+
check: new SimpleSchema({
|
|
180
|
+
collection: {
|
|
181
|
+
type: String
|
|
182
|
+
},
|
|
183
|
+
f_document: {
|
|
184
|
+
type: Object,
|
|
185
|
+
blackbox: true
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
function: function(collection: string, f_document: Object) {
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
191
|
+
reject('Invalid collection');
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document).then(res => resolve(res), err => reject(err));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
// Updates 1 document's props (from _id)
|
|
200
|
+
// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})
|
|
201
|
+
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
202
|
+
// Search for doc, check version, if found then try and update props
|
|
203
|
+
updateDocumentProps: {
|
|
204
|
+
check: new SimpleSchema({
|
|
205
|
+
collection: {
|
|
206
|
+
type: String
|
|
207
|
+
},
|
|
208
|
+
doc_id: {
|
|
209
|
+
type: String
|
|
210
|
+
},
|
|
211
|
+
updateParams: {
|
|
212
|
+
type: Array
|
|
213
|
+
},
|
|
214
|
+
'updateParams.$': {
|
|
215
|
+
type: Object,
|
|
216
|
+
blackbox: true
|
|
217
|
+
},
|
|
218
|
+
doc__v: {
|
|
219
|
+
type: Number
|
|
220
|
+
}
|
|
221
|
+
}),
|
|
222
|
+
function: function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
225
|
+
reject('Invalid collection');
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}).then(currDoc => {
|
|
229
|
+
if (currDoc) {
|
|
230
|
+
let modifiedDoc = deepCopy(currDoc);
|
|
231
|
+
|
|
232
|
+
updateParams.forEach(data => {
|
|
233
|
+
modifiedDoc[data.prop] = data.data;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
if (modifiedDoc.__v === doc__v) {
|
|
237
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc).then(res => {
|
|
238
|
+
resolve(res);
|
|
239
|
+
}, err => reject(err));
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
console.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);
|
|
243
|
+
|
|
244
|
+
if (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
245
|
+
ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
246
|
+
_id: {
|
|
247
|
+
_id: currDoc._id,
|
|
248
|
+
__v: doc__v
|
|
249
|
+
}
|
|
250
|
+
}).then(oldDoc => {
|
|
251
|
+
let newCurrDocId = currDoc._id;
|
|
252
|
+
let newCurrDocV = currDoc.__v;
|
|
253
|
+
|
|
254
|
+
if (oldDoc) {
|
|
255
|
+
let updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);
|
|
256
|
+
updatedDoc._id = newCurrDocId;
|
|
257
|
+
updatedDoc.__v = newCurrDocV;
|
|
258
|
+
currDoc._id = newCurrDocId;
|
|
259
|
+
currDoc.__v = newCurrDocV;
|
|
260
|
+
|
|
261
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc).then(res => {
|
|
262
|
+
resolve(res);
|
|
263
|
+
}, err => reject(err));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
reject('Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);
|
|
267
|
+
}
|
|
268
|
+
}, () => {});
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
reject('No Document');
|
|
277
|
+
}
|
|
278
|
+
}, () => {});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
updateDocumentOffline: {
|
|
284
|
+
check: new SimpleSchema({
|
|
285
|
+
collection: {
|
|
286
|
+
type: String
|
|
287
|
+
},
|
|
288
|
+
f_document: {
|
|
289
|
+
type: Object,
|
|
290
|
+
blackbox: true
|
|
291
|
+
}
|
|
292
|
+
}),
|
|
293
|
+
function: function(collection: string, f_document: Object) {
|
|
294
|
+
return new Promise((resolve, reject) => {
|
|
295
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
296
|
+
reject('Invalid collection');
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
ResolveIOServer.getMongoManager().collection(collection).findOne({_id: f_document['_id']}).then(currDoc => {
|
|
300
|
+
if (currDoc) {
|
|
301
|
+
if (currDoc.__v === f_document['__v']) {
|
|
302
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document, {}, false, false, currDoc).then(res => {
|
|
303
|
+
resolve(res);
|
|
304
|
+
}, err => reject(err));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);
|
|
308
|
+
|
|
309
|
+
let newCurrDocId = currDoc._id;
|
|
310
|
+
let newCurrDocV = currDoc.__v;
|
|
311
|
+
let oldDocV = f_document['__v'];
|
|
312
|
+
|
|
313
|
+
if (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
314
|
+
ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
315
|
+
_id: {
|
|
316
|
+
_id: newCurrDocId,
|
|
317
|
+
__v: oldDocV
|
|
318
|
+
}
|
|
319
|
+
}).then(oldDoc => {
|
|
320
|
+
if (oldDoc) {
|
|
321
|
+
let updatedDoc = getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);
|
|
322
|
+
updatedDoc._id = newCurrDocId;
|
|
323
|
+
updatedDoc.__v = newCurrDocV;
|
|
324
|
+
currDoc._id = newCurrDocId;
|
|
325
|
+
currDoc.__v = newCurrDocV;
|
|
326
|
+
|
|
327
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc).then(res => {
|
|
328
|
+
resolve(res);
|
|
329
|
+
}, err => reject(err));
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + oldDocV);
|
|
333
|
+
}
|
|
334
|
+
}, () => {});
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
reject('No Document');
|
|
343
|
+
}
|
|
344
|
+
}, () => {});
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
// Updates 1 document's props (from _id)
|
|
350
|
+
// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})
|
|
351
|
+
// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version
|
|
352
|
+
// Search for doc, check version, if found then try and update props
|
|
353
|
+
updateDocumentPropsOffline: {
|
|
354
|
+
check: new SimpleSchema({
|
|
355
|
+
collection: {
|
|
356
|
+
type: String
|
|
357
|
+
},
|
|
358
|
+
doc_id: {
|
|
359
|
+
type: String
|
|
360
|
+
},
|
|
361
|
+
updateParams: {
|
|
362
|
+
type: Array
|
|
363
|
+
},
|
|
364
|
+
'updateParams.$': {
|
|
365
|
+
type: Object,
|
|
366
|
+
blackbox: true
|
|
367
|
+
},
|
|
368
|
+
doc__v: {
|
|
369
|
+
type: Number
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
function: function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {
|
|
373
|
+
return new Promise((resolve, reject) => {
|
|
374
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
375
|
+
reject('Invalid collection');
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}, null, true).then(currDoc => {
|
|
379
|
+
if (currDoc) {
|
|
380
|
+
let modifiedDoc = deepCopy(currDoc);
|
|
381
|
+
|
|
382
|
+
updateParams.forEach(data => {
|
|
383
|
+
modifiedDoc[data.prop] = data.data;
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
if (modifiedDoc.__v === doc__v) {
|
|
387
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc).then(res => {
|
|
388
|
+
resolve(res);
|
|
389
|
+
}, err => reject(err));
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
console.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);
|
|
393
|
+
|
|
394
|
+
let newCurrDocId = currDoc._id;
|
|
395
|
+
let newCurrDocV = currDoc.__v;
|
|
396
|
+
|
|
397
|
+
if (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {
|
|
398
|
+
ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({
|
|
399
|
+
_id: {
|
|
400
|
+
_id: currDoc._id,
|
|
401
|
+
__v: doc__v
|
|
402
|
+
}
|
|
403
|
+
}).then(oldDoc => {
|
|
404
|
+
if (oldDoc) {
|
|
405
|
+
let updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);
|
|
406
|
+
updatedDoc._id = newCurrDocId;
|
|
407
|
+
updatedDoc.__v = newCurrDocV;
|
|
408
|
+
currDoc._id = newCurrDocId;
|
|
409
|
+
currDoc.__v = newCurrDocV;
|
|
410
|
+
|
|
411
|
+
ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc).then(res => {
|
|
412
|
+
resolve(res);
|
|
413
|
+
}, err => reject(err));
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
reject('OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);
|
|
417
|
+
}
|
|
418
|
+
}, () => {});
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
reject('Invalid Version And We Are NOT Using Versions On This Collection!');
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
reject('No Document');
|
|
427
|
+
}
|
|
428
|
+
}, () => {});
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
// Removes 1 document (from _id)
|
|
434
|
+
// @Inputs: collection, document id
|
|
435
|
+
// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted
|
|
436
|
+
// Search for doc, if found then try and remove
|
|
437
|
+
removeDocument: {
|
|
438
|
+
check: new SimpleSchema({
|
|
439
|
+
collection: {
|
|
440
|
+
type: String
|
|
441
|
+
},
|
|
442
|
+
doc_id: {
|
|
443
|
+
type: String
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
function: function(collection: string, doc_id: string) {
|
|
447
|
+
return new Promise((resolve, reject) => {
|
|
448
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
449
|
+
reject('Invalid collection');
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id}).then(res => {
|
|
453
|
+
resolve(res);
|
|
454
|
+
}, err => {
|
|
455
|
+
reject(err);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
removeDocumentWithQuery: {
|
|
462
|
+
check: new SimpleSchema({
|
|
463
|
+
collection: {
|
|
464
|
+
type: String
|
|
465
|
+
},
|
|
466
|
+
query: {
|
|
467
|
+
type: Object,
|
|
468
|
+
blackbox: true
|
|
469
|
+
}
|
|
470
|
+
}),
|
|
471
|
+
function: function(collection: string, query: Object) {
|
|
472
|
+
return new Promise((resolve, reject) => {
|
|
473
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
474
|
+
reject('Invalid collection');
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
ResolveIOServer.getMongoManager().collection(collection).deleteOne(query).then(res => {
|
|
478
|
+
resolve(res);
|
|
479
|
+
}, err => {
|
|
480
|
+
reject(err);
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
removeDocumentsWithQuery: {
|
|
487
|
+
check: new SimpleSchema({
|
|
488
|
+
collection: {
|
|
489
|
+
type: String
|
|
490
|
+
},
|
|
491
|
+
query: {
|
|
492
|
+
type: Object,
|
|
493
|
+
blackbox: true
|
|
494
|
+
}
|
|
495
|
+
}),
|
|
496
|
+
function: function(collection: string, query: Object) {
|
|
497
|
+
return new Promise((resolve, reject) => {
|
|
498
|
+
if (!ResolveIOServer.getMongoManager().collection(collection)) {
|
|
499
|
+
reject('Invalid collection');
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
ResolveIOServer.getMongoManager().collection(collection).deleteMany(query).then(res => {
|
|
503
|
+
resolve(res);
|
|
504
|
+
}, err => {
|
|
505
|
+
reject(err);
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { MethodManager } from '../managers/method.manager';
|
|
2
|
+
import { Counters } from '../collections/counter.collection';
|
|
3
|
+
import SimpleSchema from 'simpl-schema';
|
|
4
|
+
import { ResolveIOServer } from '..';
|
|
5
|
+
import { objectIdHexString } from '../managers/mongo.manager';
|
|
6
|
+
|
|
7
|
+
export function loadCounterMethods(methodManager: MethodManager) {
|
|
8
|
+
methodManager.methods({
|
|
9
|
+
incCounter: {
|
|
10
|
+
check: new SimpleSchema({
|
|
11
|
+
counterType: {
|
|
12
|
+
type: String
|
|
13
|
+
}
|
|
14
|
+
}),
|
|
15
|
+
function: function(counterType: string) {
|
|
16
|
+
return new Promise(async (resolve, reject) => {
|
|
17
|
+
let counter = await Counters.findOne({type: counterType});
|
|
18
|
+
|
|
19
|
+
if (!counter) {
|
|
20
|
+
Counters.create({
|
|
21
|
+
_id: objectIdHexString(),
|
|
22
|
+
count: 2,
|
|
23
|
+
type: counterType
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
resolve(1);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
let newCount = await Counters.findOneAndUpdate({type: counterType}, {$inc: {count: 1}});
|
|
30
|
+
|
|
31
|
+
resolve(newCount.count);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
countCollectionWithQuery: {
|
|
37
|
+
check: new SimpleSchema({
|
|
38
|
+
collectionType: {
|
|
39
|
+
type: String
|
|
40
|
+
},
|
|
41
|
+
query: {
|
|
42
|
+
type: Object,
|
|
43
|
+
blackbox: true
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
function: function(collectionType: string, query: Object) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
if (!ResolveIOServer.getMongoManager().collection(collectionType)) {
|
|
49
|
+
reject('Invalid collection');
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
ResolveIOServer.getMongoManager().collection(collectionType).countDocuments(query).then(res => resolve(res), err => reject(err));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
countCollection: {
|
|
58
|
+
check: new SimpleSchema({
|
|
59
|
+
collectionType: {
|
|
60
|
+
type: String
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
function: function(collectionType: string) {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
if (!ResolveIOServer.getMongoManager().collection(collectionType)) {
|
|
66
|
+
reject('Invalid collection');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
ResolveIOServer.getMongoManager().collection(collectionType).countDocuments().then(res => resolve(res), err => reject(err));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|