flamerest 1.0.55 → 1.0.58
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/REST.d.ts +3 -3
- package/REST.js +6 -6
- package/package.json +1 -1
package/REST.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function request(url: string, params: object | string, type?: string, res
|
|
|
21
21
|
* @param titles Это чтобы мы могли контроллить какие названия полей мы будет загружать при экспорте, чтобы они были как в таблице
|
|
22
22
|
* @return Promise<object>
|
|
23
23
|
*/
|
|
24
|
-
export function get<T>(table: string, where?: object | string | null,
|
|
24
|
+
export function get<T>(table: string, where?: object | string | null, extfields?: object | Array<string>, fields?: object | Array<string> | string | null, sortfields?: object | Array<string> | string | null, page?: number, perPage?: number, RemoveDuplicates?, format?, titles?): Promise<Rows<T>>;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Получить все записи по запросу [постранично]
|
|
@@ -29,7 +29,7 @@ export function get<T>(table: string, where?: object | string | null, expand?: o
|
|
|
29
29
|
* @param {object} params
|
|
30
30
|
* @returns
|
|
31
31
|
*/
|
|
32
|
-
export function all<T>(table: string, params?: { where?: object, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number, tree?: number }): Promise<Rows<T>>;
|
|
32
|
+
export function all<T>(table: string, params?: { where?: object, extfields?: object | Array<string>, fields?: object | Array<string>, sort?: Array<string>, page?: number, perPage?: number, tree?: number }): Promise<Rows<T>>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Стандартный ответ от Request с несколькими строками
|
|
@@ -56,7 +56,7 @@ type Rows<T> = {
|
|
|
56
56
|
* @param {object|Array} fields
|
|
57
57
|
* @param {string} primaryKeyName если указан ID, то указать название первичного ключа, если от id он отличается
|
|
58
58
|
*/
|
|
59
|
-
export function one<T>(table: string, IDOrWhere: number | string | object, fields?: object | Array<string> | null, primaryKeyName?: string): Promise<T | null>;
|
|
59
|
+
export function one<T>(table: string, IDOrWhere: number | string | object, extfields?: object | Array<string>, fields?: object | Array<string> | null, primaryKeyName?: string): Promise<T | null>;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Создать новую запись
|
package/REST.js
CHANGED
|
@@ -298,7 +298,7 @@ class FLAMEREST {
|
|
|
298
298
|
* @param tree дерево
|
|
299
299
|
* @return Promise<>
|
|
300
300
|
*/
|
|
301
|
-
get(table, where,
|
|
301
|
+
get(table, where, extfields, fields, sortfields, page, perPage, RemoveDuplicates, format, titles, tree) {
|
|
302
302
|
|
|
303
303
|
// Нормализуем имена таблиц
|
|
304
304
|
table = table.replace(/_/g, "");
|
|
@@ -327,8 +327,8 @@ class FLAMEREST {
|
|
|
327
327
|
if (sortfields !== undefined && sortfields !== null)
|
|
328
328
|
json.sort = sortfields;
|
|
329
329
|
|
|
330
|
-
if (
|
|
331
|
-
json.
|
|
330
|
+
if (extfields !== undefined && extfields !== null)
|
|
331
|
+
json.extfields = extfields;
|
|
332
332
|
|
|
333
333
|
if (RemoveDuplicates !== undefined && RemoveDuplicates !== null)
|
|
334
334
|
json.RemoveDuplicates = true;
|
|
@@ -355,7 +355,7 @@ class FLAMEREST {
|
|
|
355
355
|
* @returns {object}
|
|
356
356
|
*/
|
|
357
357
|
all(table, params) {
|
|
358
|
-
return this.get(table, params?.where,
|
|
358
|
+
return this.get(table, params?.where, params?.extfields, params?.fields, params?.sort, params?.page, params?.perPage, null, null, null, params?.tree);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
/**
|
|
@@ -366,14 +366,14 @@ class FLAMEREST {
|
|
|
366
366
|
* @param {string} primaryKeyName
|
|
367
367
|
* @returns {object|null}
|
|
368
368
|
*/
|
|
369
|
-
async one(table, IDOrWhere, fields = null, primaryKeyName = 'id') {
|
|
369
|
+
async one(table, IDOrWhere, extfields = null, fields = null, primaryKeyName = 'id') {
|
|
370
370
|
|
|
371
371
|
let where = {};
|
|
372
372
|
if (typeof IDOrWhere === 'string' || typeof IDOrWhere === 'number') where = { [primaryKeyName]: IDOrWhere };
|
|
373
373
|
else if (typeof IDOrWhere === 'object') where = IDOrWhere;
|
|
374
374
|
else throw "Нужно передавать ID или объект";
|
|
375
375
|
|
|
376
|
-
let resp = await this.get(table, where,
|
|
376
|
+
let resp = await this.get(table, where, extfields, fields, null, 1, 1);
|
|
377
377
|
if (resp.errors) return resp;
|
|
378
378
|
if (resp.data.length === 0) return null;
|
|
379
379
|
|