@crowdin/app-project-module 0.96.2 → 0.97.0

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.
@@ -76,6 +76,7 @@ export interface Storage {
76
76
  whereClause?: string;
77
77
  orderBy?: string;
78
78
  limit?: number;
79
+ offset?: number;
79
80
  distinct?: boolean;
80
81
  }, params?: any[]): Promise<any[]>;
81
82
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -97,6 +97,7 @@ export declare class MySQLStorage implements Storage {
97
97
  whereClause?: string;
98
98
  orderBy?: string;
99
99
  limit?: number;
100
+ offset?: number;
100
101
  distinct?: boolean;
101
102
  }, params?: any[]): Promise<any[]>;
102
103
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -873,7 +873,13 @@ class MySQLStorage {
873
873
  const distinctKeyword = options.distinct ? 'DISTINCT ' : '';
874
874
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
875
875
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
876
- const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
876
+ let limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
877
+ if (!options.limit && options.offset) {
878
+ throw new Error('[selectRecords] Limit is required for pagination with MySQL');
879
+ }
880
+ else if (options.limit && options.offset) {
881
+ limitClause += ` OFFSET ${options.offset}`;
882
+ }
877
883
  const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
878
884
  return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
879
885
  const [rows] = yield connection.execute(query, params);
@@ -108,6 +108,7 @@ export declare class PostgreStorage implements Storage {
108
108
  whereClause?: string;
109
109
  orderBy?: string;
110
110
  limit?: number;
111
+ offset?: number;
111
112
  distinct?: boolean;
112
113
  }, params?: any[]): Promise<any[]>;
113
114
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -886,7 +886,8 @@ class PostgreStorage {
886
886
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
887
887
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
888
888
  const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
889
- const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
889
+ const offsetClause = options.offset ? ` OFFSET ${options.offset}` : '';
890
+ const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause}${offsetClause};`;
890
891
  return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
891
892
  const res = yield client.query(query, params);
892
893
  return res.rows;
@@ -95,6 +95,7 @@ export declare class SQLiteStorage implements Storage {
95
95
  whereClause?: string;
96
96
  orderBy?: string;
97
97
  limit?: number;
98
+ offset?: number;
98
99
  distinct?: boolean;
99
100
  }, params?: any[]): Promise<any[]>;
100
101
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -745,7 +745,8 @@ class SQLiteStorage {
745
745
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
746
746
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
747
747
  const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
748
- const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
748
+ const offsetClause = options.offset ? ` OFFSET ${options.offset}` : '';
749
+ const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause}${offsetClause};`;
749
750
  return this.each(query, params);
750
751
  });
751
752
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.96.2",
3
+ "version": "0.97.0",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",