flamerest 1.0.56 → 1.0.59
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 +10 -10
- package/REST.js +2 -2
- 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,23 +29,23 @@ 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 с несколькими строками
|
|
36
36
|
*/
|
|
37
37
|
type Rows<T> = {
|
|
38
38
|
type: string,
|
|
39
|
-
status:
|
|
39
|
+
status: number,
|
|
40
40
|
ok: boolean,
|
|
41
41
|
data?: Array<T>,
|
|
42
|
-
errors:
|
|
42
|
+
errors: object | undefined,
|
|
43
43
|
message: string | undefined,
|
|
44
44
|
pages: {
|
|
45
|
-
page:
|
|
46
|
-
perPage:
|
|
47
|
-
count:
|
|
48
|
-
total:
|
|
45
|
+
page: number,
|
|
46
|
+
perPage: number,
|
|
47
|
+
count: number,
|
|
48
|
+
total: number,
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -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
|
* Создать новую запись
|
|
@@ -121,7 +121,7 @@ type Authorized = {
|
|
|
121
121
|
User: {
|
|
122
122
|
avatar: string,
|
|
123
123
|
country: string,
|
|
124
|
-
id:
|
|
124
|
+
id: number,
|
|
125
125
|
lang: string,
|
|
126
126
|
name: string,
|
|
127
127
|
role: string
|
package/REST.js
CHANGED
|
@@ -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
|
|