@formio/appserver 2.12.0 → 2.12.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.
@@ -70,7 +70,7 @@ export declare class Database implements ServerDB {
70
70
  * @param {*} table
71
71
  * @param {*} query
72
72
  */
73
- index(form: AppServerForm, query: IndexQuery, collection?: Collection<Document> | null): Promise<DatabaseIndexResponse<Submission>>;
73
+ index(form: AppServerForm, query?: IndexQuery, collection?: Collection<Document> | null): Promise<DatabaseIndexResponse<Submission>>;
74
74
  /**
75
75
  * Perform a count of the amount of documents within a collection.
76
76
  * @param form
@@ -429,13 +429,18 @@ class Database {
429
429
  skip = parseInt(urlQuery.skip) || 0;
430
430
  let sort = { created: -1 };
431
431
  if (urlQuery.sort) {
432
- sort = {};
433
- const sortParts = urlQuery.sort.split(',');
434
- sortParts.forEach((part) => {
435
- const desc = part.charAt(0) === '-';
436
- const field = desc ? part.substring(1) : part;
437
- sort[field] = desc ? -1 : 1;
438
- });
432
+ if (typeof urlQuery.sort === 'string') {
433
+ sort = {};
434
+ const sortParts = urlQuery.sort.split(',');
435
+ sortParts.forEach((part) => {
436
+ const desc = part.charAt(0) === '-';
437
+ const field = desc ? part.substring(1) : part;
438
+ sort[field] = desc ? -1 : 1;
439
+ });
440
+ }
441
+ else {
442
+ sort = urlQuery.sort;
443
+ }
439
444
  }
440
445
  const includeDeleted = urlQuery.includeDeleted || false;
441
446
  let project = {};
@@ -471,8 +476,8 @@ class Database {
471
476
  * @param {*} table
472
477
  * @param {*} query
473
478
  */
474
- index(form_1, query_1) {
475
- return __awaiter(this, arguments, void 0, function* (form, query, collection = null) {
479
+ index(form_1) {
480
+ return __awaiter(this, arguments, void 0, function* (form, query = { limit: 10, skip: 0, sort: { created: -1 }, includeDeleted: false, dbQuery: {} }, collection = null) {
476
481
  let items = [], count = 0;
477
482
  const { limit, skip, sort, includeDeleted, project, dbQuery } = query;
478
483
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/appserver",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "A highly performant and extensible Application Server for Form.io Multi-Tenant Deployments.",
5
5
  "main": "lib/server.js",
6
6
  "types": "lib/server.d.ts",
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "homepage": "https://github.com/formio/appserver#readme",
35
35
  "dependencies": {
36
- "@formio/appserver-core": "^2.12.0",
36
+ "@formio/appserver-core": "^2.12.1",
37
37
  "@formio/core": "2.5.1-dev.291.6557e4e",
38
38
  "async": "^3.2.6",
39
39
  "bcryptjs": "^3.0.3",