@saltcorn/data 0.8.9 → 0.9.0-beta.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.
Files changed (47) hide show
  1. package/dist/base-plugin/fieldviews.d.ts.map +1 -1
  2. package/dist/base-plugin/fieldviews.js +23 -1
  3. package/dist/base-plugin/fieldviews.js.map +1 -1
  4. package/dist/base-plugin/index.d.ts +328 -322
  5. package/dist/base-plugin/index.d.ts.map +1 -1
  6. package/dist/base-plugin/types.d.ts +11 -0
  7. package/dist/base-plugin/types.d.ts.map +1 -1
  8. package/dist/base-plugin/types.js +6 -0
  9. package/dist/base-plugin/types.js.map +1 -1
  10. package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
  11. package/dist/base-plugin/viewtemplates/edit.js +14 -5
  12. package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
  13. package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -1
  14. package/dist/base-plugin/viewtemplates/list.js +1 -0
  15. package/dist/base-plugin/viewtemplates/list.js.map +1 -1
  16. package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
  17. package/dist/base-plugin/viewtemplates/viewable_fields.js +21 -5
  18. package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
  19. package/dist/models/config.d.ts.map +1 -1
  20. package/dist/models/config.js +6 -0
  21. package/dist/models/config.js.map +1 -1
  22. package/dist/models/field.d.ts +4 -0
  23. package/dist/models/field.d.ts.map +1 -1
  24. package/dist/models/field.js +1 -0
  25. package/dist/models/field.js.map +1 -1
  26. package/dist/models/file.js +1 -1
  27. package/dist/models/file.js.map +1 -1
  28. package/dist/models/index.d.ts +1 -1
  29. package/dist/models/internal/table_helper.d.ts +33 -0
  30. package/dist/models/internal/table_helper.d.ts.map +1 -0
  31. package/dist/models/internal/table_helper.js +134 -0
  32. package/dist/models/internal/table_helper.js.map +1 -0
  33. package/dist/models/table.d.ts +156 -19
  34. package/dist/models/table.d.ts.map +1 -1
  35. package/dist/models/table.js +131 -15
  36. package/dist/models/table.js.map +1 -1
  37. package/dist/models/user.d.ts.map +1 -1
  38. package/dist/models/user.js +1 -2
  39. package/dist/models/user.js.map +1 -1
  40. package/dist/plugin-helper.d.ts +1 -1
  41. package/dist/plugin-helper.d.ts.map +1 -1
  42. package/dist/plugin-helper.js +13 -1
  43. package/dist/plugin-helper.js.map +1 -1
  44. package/dist/tests/exact_views.test.js +14 -14
  45. package/dist/tests/exact_views.test.js.map +1 -1
  46. package/package.json +7 -7
  47. package/webpack.config.js +2 -0
@@ -7,24 +7,114 @@ import type TableConstraint from "./table_constraints";
7
7
  import type { AbstractTag } from "@saltcorn/types/model-abstracts/abstract_tag";
8
8
  import type { JoinFieldOption, RelationOption } from "@saltcorn/types/base_types";
9
9
  /**
10
- * Table class
10
+ * A class representing database tables and their properties.
11
+ *
12
+ * Use this to create or delete tables and their properties, or to query
13
+ * or change table rows.
14
+ *
15
+ * To query, update, insert or delete rows in an existing table, first you
16
+ * should find the table object with {@link Table.findOne}.
17
+ *
18
+ * @example
19
+ * ```
20
+ * Table.findOne({name: "Customers"}) // find the table with name "Customers"
21
+ * Table.findOne("Customers") // find the table with name "Customers" (shortcut)
22
+ * Table.findOne({ id: 5 }) // find the table with id=5
23
+ * Table.findOne(5) // find the table with id=5 (shortcut)
24
+ * ```
25
+ *
26
+ * Table.findOne is synchronous (no need to await), But the functions that
27
+ * query and manipulate (such as {@link Table.insertRow}, {@link Table.getRows},
28
+ * {@link Table.updateRow}, {@link Table.deleteRows}) rows are mostly asyncronous,
29
+ * so you can put the await in front of the
30
+ * whole expression
31
+ *
32
+ * @example
33
+ * To count the number of rows in the customer table
34
+ * ```
35
+ * const nrows = await Table.findOne("Customers").countRows()
36
+ * ```
37
+ *
38
+ * For further examples, see the [Table test suite](https://github.com/saltcorn/saltcorn/blob/master/packages/saltcorn-data/tests/table.test.ts)
39
+ *
40
+ * ## Querying table rows
41
+ *
42
+ * There are several methods you can use to retrieve rows in the database:
43
+ *
44
+ * * {@link Table.countRows} To count the number of rows, optionally matching a criterion
45
+ * * {@link Table.getRows} To retrieve multiple rows matching a criterion
46
+ * * {@link Table.getRow} To retrieve a single row matching a criterion
47
+ * * {@link Table.getJoinedRows} To retrieve rows together with joinfields and aggregations
48
+ *
49
+ * These functions all take `Where` expressions which are JavaScript objects describing
50
+ * the criterion to match to. Some examples:
51
+ *
52
+ * * `{ name: "Jim" }`: Match all rows with name="Jim"
53
+ * * `{ name: { ilike: "im"} }`: Match all rows where name contains "im" (case insensitive)
54
+ * * `{ age: { lt: 18 } }`: Match all rows with age<18
55
+ * * `{ age: { lt: 18, equal: true } }`: Match all rows with age<=18
56
+ * * `{ age: { gt: 18, lt: 65} }`: Match all rows with 18<age<65
57
+ * * `{ name: { or: ["Harry", "Sally"] } }`: Match all rows with name="Harry" or "Sally"
58
+ * * `{ or: [{ name: "Joe"}, { age: 37 }] }`: Match all rows with name="Joe" or age=37
59
+ * * `{ not: { id: 5 } }`: All rows except id=5
60
+ *
61
+ * For further examples, see the [mkWhere test suite](https://github.com/saltcorn/saltcorn/blob/master/packages/db-common/internal.test.js)
62
+ *
63
+ * ## Updating a Row
64
+ *
65
+ * There are two nearly identical functions for updating rows depending on how you want
66
+ * failures treated
67
+ *
68
+ * * {@link Table.updateRow} Update a row, throws an exception if update is invalid
69
+ * * {@link Table.tryUpdateRow} Update a row, return an error message if update is invalid
70
+ *
71
+ * ## Inserting a new Row
72
+ *
73
+ * There are two nearly identical functions for inserting a new row depending on how you want
74
+ * failures treated
75
+ *
76
+ * * {@link Table.insertRow} insert a row, throws an exception if it is invalid
77
+ * * {@link Table.tryInsertRow} insert a row, return an error message if it is invalid
78
+ *
79
+ * ## Deleting rows
80
+ *
81
+ * Use {@link Table.deleteRows} to delete any number (zero, one or many) of rows matching a criterion. It uses
82
+ * the same `where` expression as the functions for querying rows
83
+ *
84
+ *
11
85
  * @category saltcorn-data
12
86
  */
13
87
  declare class Table implements AbstractTable {
88
+ /** The table name */
14
89
  name: string;
90
+ /** The table ID */
15
91
  id?: number;
92
+ /** Minimum role to read */
16
93
  min_role_read: number;
94
+ /** Minimum role to write */
17
95
  min_role_write: number;
96
+ /** The ID of the ownership field*/
18
97
  ownership_field_id?: string;
98
+ /** A formula to denote ownership. This is a JavaScript expression which
99
+ * must evaluate to true if the user is the owner*/
19
100
  ownership_formula?: string;
101
+ /** Version history enabled for this table */
20
102
  versioned: boolean;
103
+ /** Whether sync info for mobile apps is enabled for this table */
21
104
  has_sync_info: boolean;
105
+ /** If true this is an external table (not a database table) */
22
106
  external: boolean;
107
+ /** A description of the purpose of the table */
23
108
  description?: string;
109
+ /** An array of {@link Field}s in this table */
24
110
  fields: Field[];
111
+ /** An array of {@link TableConstraint}s for this table */
25
112
  constraints: TableConstraint[];
113
+ /** Is this a user group? If yes it will appear as options in the ownership dropdown */
26
114
  is_user_group: boolean;
115
+ /** Name of the table provider for this table (not a database table) */
27
116
  provider_name?: string;
117
+ /** Configuration for the table provider for this table */
28
118
  provider_cfg?: any;
29
119
  /**
30
120
  * Table constructor
@@ -121,10 +211,8 @@ declare class Table implements AbstractTable {
121
211
  * @param user
122
212
  * @param forRead
123
213
  */
124
- updateWhereWithOwnership(where: Where, fields: Field[], user?: Row, forRead?: boolean): {
125
- notAuthorized?: boolean;
126
- } | undefined;
127
- addDeleteSyncInfo(ids: Row[], timestamp: Date): Promise<void>;
214
+ private updateWhereWithOwnership;
215
+ private addDeleteSyncInfo;
128
216
  /**
129
217
  * Delete rows from table
130
218
  * @param where - condition
@@ -137,7 +225,7 @@ declare class Table implements AbstractTable {
137
225
  * @param row
138
226
  * @returns {*}
139
227
  */
140
- readFromDB(row: Row): any;
228
+ private readFromDB;
141
229
  /**
142
230
  * Get one row from table in db
143
231
  * @param where
@@ -168,7 +256,7 @@ declare class Table implements AbstractTable {
168
256
  /**
169
257
  *
170
258
  */
171
- storedExpressionJoinFields(): {};
259
+ private storedExpressionJoinFields;
172
260
  /**
173
261
  * Update row
174
262
  * @param v_in - columns with values to update
@@ -181,8 +269,8 @@ declare class Table implements AbstractTable {
181
269
  updateRow(v_in: any, id: number, user?: Row, noTrigger?: boolean, resultCollector?: object, restore_of_version?: any, syncTimestamp?: Date): Promise<string | void>;
182
270
  latestSyncInfo(id: number): Promise<any>;
183
271
  latestSyncInfos(ids: number[]): Promise<any>;
184
- insertSyncInfo(id: number, syncTimestamp?: Date): Promise<void>;
185
- updateSyncInfo(id: number, oldLastModified: Date, syncTimestamp?: Date): Promise<void>;
272
+ private insertSyncInfo;
273
+ private updateSyncInfo;
186
274
  /**
187
275
  * Try to Update row
188
276
  * @param v
@@ -200,12 +288,14 @@ declare class Table implements AbstractTable {
200
288
  */
201
289
  toggleBool(id: any, field_name: string, user?: Row): Promise<void>;
202
290
  /**
203
- * Get primary key field
291
+ * Get primary key field name
204
292
  * @type {string}
205
293
  */
206
294
  get pk_name(): string;
207
295
  /**
208
- * Check table constraints
296
+ * Check table constraints against a row object. Will return a string With an error message if the
297
+ * table constraints are violated, `undefined` if the row does not violate any constraints
298
+ *
209
299
  * @param row
210
300
  */
211
301
  check_table_constraints(row0: Row): string | undefined;
@@ -214,11 +304,25 @@ declare class Table implements AbstractTable {
214
304
  * @param row
215
305
  * @param user
216
306
  */
217
- check_field_write_role(row: Row, user: Row): string | undefined;
307
+ private check_field_write_role;
218
308
  /**
219
- * Insert row
309
+ * Insert row into the table. By passing in the user as
310
+ * the second argument, tt will check write rights. If a user object is not
311
+ * supplied, the insert goes ahead without checking write permissions.
312
+ *
313
+ * Returns the primary key value of the inserted row.
314
+ *
315
+ * This will throw an exception if the row
316
+ * does not conform to the table constraints. If you would like to insert a row
317
+ * with a function that can return an error message, use {@link Table.tryInsertRow} instead.
318
+ *
319
+ * @example
320
+ * ```
321
+ * await Table.findOne("People").insertRow({ name: "Jim", age: 35 })
322
+ * ```
323
+ *
220
324
  * @param v_in
221
- * @param _userid
325
+ * @param user
222
326
  * @param resultCollector
223
327
  * @returns {Promise<*>}
224
328
  */
@@ -239,7 +343,7 @@ declare class Table implements AbstractTable {
239
343
  *
240
344
  * @param msg
241
345
  */
242
- normalise_error_message(msg: string): string;
346
+ private normalise_error_message;
243
347
  /**
244
348
  * Get Fields list for table
245
349
  * @returns {Promise<Field[]>}
@@ -259,9 +363,9 @@ declare class Table implements AbstractTable {
259
363
  * Create history table
260
364
  * @returns {Promise<void>}
261
365
  */
262
- create_history_table(): Promise<void>;
263
- create_sync_info_table(): Promise<void>;
264
- drop_sync_table(): Promise<void>;
366
+ private create_history_table;
367
+ private create_sync_info_table;
368
+ private drop_sync_table;
265
369
  /**
266
370
  * Restore Row Version
267
371
  * @param id
@@ -285,7 +389,7 @@ declare class Table implements AbstractTable {
285
389
  * Drop history table
286
390
  * @returns {Promise<void>}
287
391
  */
288
- drop_history_table(): Promise<void>;
392
+ private drop_history_table;
289
393
  /**
290
394
  * Rename table
291
395
  * @param new_name
@@ -383,6 +487,38 @@ declare class Table implements AbstractTable {
383
487
  */
384
488
  getJoinedRow(opts?: (JoinOptions & ForUserRequest) | any): Promise<Row | null>;
385
489
  /**
490
+ * Get rows along with joined and aggregated fields. The argument to `getJoinedRows` is an object
491
+ * with several different possible fields, all of which are optional
492
+ *
493
+ * * `where`: A Where expression indicating the criterion to match
494
+ * * `joinFields`: An object with the joinfields to retrieve
495
+ * * `aggregations`: An object with the aggregations to retrieve
496
+ * * `orderBy`: A string with the name of the field to order by
497
+ * * `orderDesc`: If true, descending order
498
+ * * `limit`: A number with the maximum number of rows to retrieve
499
+ * * `offset`: The number of rows to skip in the result before returning rows
500
+ *
501
+ * @example
502
+ * ```
503
+ * const patients = Table.findOne({ name: "patients" });
504
+ * const patients_rows = await patients.getJoinedRows({
505
+ * where: { age: { gt: 65 } },
506
+ * orderBy: "id",
507
+ * aggregations: {
508
+ * avg_temp: {
509
+ * table: "readings",
510
+ * ref: "patient_id",
511
+ * field: "temperature",
512
+ * aggregate: "avg",
513
+ * },
514
+ * },
515
+ * joinFields: {
516
+ * pages: { ref: "favbook", target: "pages" },
517
+ * author: { ref: "favbook", target: "author" },
518
+ * },
519
+ * });
520
+ * ```
521
+ *
386
522
  * @param {object} [opts = {}]
387
523
  * @returns {Promise<object[]>}
388
524
  */
@@ -411,6 +547,7 @@ declare class Table implements AbstractTable {
411
547
  *
412
548
  */
413
549
  getForeignTables(): Promise<Array<AbstractTable>>;
550
+ getFormulaExamples(typename: string): string[];
414
551
  }
415
552
  declare namespace Table {
416
553
  type ParentRelations = {
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../models/table.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,GAAG,EAEH,WAAW,EAEZ,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACV,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,+CAA+C,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAmBlE,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAC;AA0BvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,4BAA4B,CAAC;AAwDpC;;;GAGG;AACH,cAAM,KAAM,YAAW,aAAa;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EA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AK,CAAC,eAAe,CAAC;AAC7C,aAAK,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;AAC3C,aAAK,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;AAEvC,SAAS,KAAK,CAAC"}
@@ -48,6 +48,7 @@ const utils_1 = __importDefault(require("../utils"));
48
48
  const { prefixFieldsInWhere, InvalidConfiguration, InvalidAdminAction, satisfies, structuredClone, getLines, mergeIntoWhere, stringToJSON, isNode, apply, applyAsync, asyncMap, } = utils_1.default;
49
49
  const tags_1 = __importDefault(require("@saltcorn/markup/tags"));
50
50
  const { text } = tags_1.default;
51
+ const table_helper_1 = require("./internal/table_helper");
51
52
  /**
52
53
  * Transponce Objects
53
54
  * TODO more detailed explanation
@@ -84,18 +85,82 @@ const dateFormats = [moment_1.default.ISO_8601];
84
85
  const isDate = function (date) {
85
86
  return (0, moment_1.default)(date, dateFormats, true).isValid();
86
87
  };
87
- // todo resolve database specific
88
88
  /**
89
- * Normalise specific error message according db specific
90
- * @param msg
91
- * @returns {string}
92
- */
93
- // todo refactor
94
- const normalise_error_message = (msg) => db_1.default.isSQLite
95
- ? msg.replace(/SQLITE_CONSTRAINT: UNIQUE constraint failed: (.*?)\.(.*?)/, "Duplicate value for unique field: $2")
96
- : msg.replace(/duplicate key value violates unique constraint "(.*?)_(.*?)_unique"/, "Duplicate value for unique field: $2");
97
- /**
98
- * Table class
89
+ * A class representing database tables and their properties.
90
+ *
91
+ * Use this to create or delete tables and their properties, or to query
92
+ * or change table rows.
93
+ *
94
+ * To query, update, insert or delete rows in an existing table, first you
95
+ * should find the table object with {@link Table.findOne}.
96
+ *
97
+ * @example
98
+ * ```
99
+ * Table.findOne({name: "Customers"}) // find the table with name "Customers"
100
+ * Table.findOne("Customers") // find the table with name "Customers" (shortcut)
101
+ * Table.findOne({ id: 5 }) // find the table with id=5
102
+ * Table.findOne(5) // find the table with id=5 (shortcut)
103
+ * ```
104
+ *
105
+ * Table.findOne is synchronous (no need to await), But the functions that
106
+ * query and manipulate (such as {@link Table.insertRow}, {@link Table.getRows},
107
+ * {@link Table.updateRow}, {@link Table.deleteRows}) rows are mostly asyncronous,
108
+ * so you can put the await in front of the
109
+ * whole expression
110
+ *
111
+ * @example
112
+ * To count the number of rows in the customer table
113
+ * ```
114
+ * const nrows = await Table.findOne("Customers").countRows()
115
+ * ```
116
+ *
117
+ * For further examples, see the [Table test suite](https://github.com/saltcorn/saltcorn/blob/master/packages/saltcorn-data/tests/table.test.ts)
118
+ *
119
+ * ## Querying table rows
120
+ *
121
+ * There are several methods you can use to retrieve rows in the database:
122
+ *
123
+ * * {@link Table.countRows} To count the number of rows, optionally matching a criterion
124
+ * * {@link Table.getRows} To retrieve multiple rows matching a criterion
125
+ * * {@link Table.getRow} To retrieve a single row matching a criterion
126
+ * * {@link Table.getJoinedRows} To retrieve rows together with joinfields and aggregations
127
+ *
128
+ * These functions all take `Where` expressions which are JavaScript objects describing
129
+ * the criterion to match to. Some examples:
130
+ *
131
+ * * `{ name: "Jim" }`: Match all rows with name="Jim"
132
+ * * `{ name: { ilike: "im"} }`: Match all rows where name contains "im" (case insensitive)
133
+ * * `{ age: { lt: 18 } }`: Match all rows with age<18
134
+ * * `{ age: { lt: 18, equal: true } }`: Match all rows with age<=18
135
+ * * `{ age: { gt: 18, lt: 65} }`: Match all rows with 18<age<65
136
+ * * `{ name: { or: ["Harry", "Sally"] } }`: Match all rows with name="Harry" or "Sally"
137
+ * * `{ or: [{ name: "Joe"}, { age: 37 }] }`: Match all rows with name="Joe" or age=37
138
+ * * `{ not: { id: 5 } }`: All rows except id=5
139
+ *
140
+ * For further examples, see the [mkWhere test suite](https://github.com/saltcorn/saltcorn/blob/master/packages/db-common/internal.test.js)
141
+ *
142
+ * ## Updating a Row
143
+ *
144
+ * There are two nearly identical functions for updating rows depending on how you want
145
+ * failures treated
146
+ *
147
+ * * {@link Table.updateRow} Update a row, throws an exception if update is invalid
148
+ * * {@link Table.tryUpdateRow} Update a row, return an error message if update is invalid
149
+ *
150
+ * ## Inserting a new Row
151
+ *
152
+ * There are two nearly identical functions for inserting a new row depending on how you want
153
+ * failures treated
154
+ *
155
+ * * {@link Table.insertRow} insert a row, throws an exception if it is invalid
156
+ * * {@link Table.tryInsertRow} insert a row, return an error message if it is invalid
157
+ *
158
+ * ## Deleting rows
159
+ *
160
+ * Use {@link Table.deleteRows} to delete any number (zero, one or many) of rows matching a criterion. It uses
161
+ * the same `where` expression as the functions for querying rows
162
+ *
163
+ *
99
164
  * @category saltcorn-data
100
165
  */
101
166
  class Table {
@@ -984,7 +1049,7 @@ class Table {
984
1049
  await this.updateRow({ [field_name]: !row[field_name] }, id, user);
985
1050
  }
986
1051
  /**
987
- * Get primary key field
1052
+ * Get primary key field name
988
1053
  * @type {string}
989
1054
  */
990
1055
  get pk_name() {
@@ -995,7 +1060,9 @@ class Table {
995
1060
  return pkField;
996
1061
  }
997
1062
  /**
998
- * Check table constraints
1063
+ * Check table constraints against a row object. Will return a string With an error message if the
1064
+ * table constraints are violated, `undefined` if the row does not violate any constraints
1065
+ *
999
1066
  * @param row
1000
1067
  */
1001
1068
  check_table_constraints(row0) {
@@ -1028,9 +1095,23 @@ class Table {
1028
1095
  return undefined;
1029
1096
  }
1030
1097
  /**
1031
- * Insert row
1098
+ * Insert row into the table. By passing in the user as
1099
+ * the second argument, tt will check write rights. If a user object is not
1100
+ * supplied, the insert goes ahead without checking write permissions.
1101
+ *
1102
+ * Returns the primary key value of the inserted row.
1103
+ *
1104
+ * This will throw an exception if the row
1105
+ * does not conform to the table constraints. If you would like to insert a row
1106
+ * with a function that can return an error message, use {@link Table.tryInsertRow} instead.
1107
+ *
1108
+ * @example
1109
+ * ```
1110
+ * await Table.findOne("People").insertRow({ name: "Jim", age: 35 })
1111
+ * ```
1112
+ *
1032
1113
  * @param v_in
1033
- * @param _userid
1114
+ * @param user
1034
1115
  * @param resultCollector
1035
1116
  * @returns {Promise<*>}
1036
1117
  */
@@ -2237,6 +2318,38 @@ class Table {
2237
2318
  return rows.length > 0 ? rows[0] : null;
2238
2319
  }
2239
2320
  /**
2321
+ * Get rows along with joined and aggregated fields. The argument to `getJoinedRows` is an object
2322
+ * with several different possible fields, all of which are optional
2323
+ *
2324
+ * * `where`: A Where expression indicating the criterion to match
2325
+ * * `joinFields`: An object with the joinfields to retrieve
2326
+ * * `aggregations`: An object with the aggregations to retrieve
2327
+ * * `orderBy`: A string with the name of the field to order by
2328
+ * * `orderDesc`: If true, descending order
2329
+ * * `limit`: A number with the maximum number of rows to retrieve
2330
+ * * `offset`: The number of rows to skip in the result before returning rows
2331
+ *
2332
+ * @example
2333
+ * ```
2334
+ * const patients = Table.findOne({ name: "patients" });
2335
+ * const patients_rows = await patients.getJoinedRows({
2336
+ * where: { age: { gt: 65 } },
2337
+ * orderBy: "id",
2338
+ * aggregations: {
2339
+ * avg_temp: {
2340
+ * table: "readings",
2341
+ * ref: "patient_id",
2342
+ * field: "temperature",
2343
+ * aggregate: "avg",
2344
+ * },
2345
+ * },
2346
+ * joinFields: {
2347
+ * pages: { ref: "favbook", target: "pages" },
2348
+ * author: { ref: "favbook", target: "author" },
2349
+ * },
2350
+ * });
2351
+ * ```
2352
+ *
2240
2353
  * @param {object} [opts = {}]
2241
2354
  * @returns {Promise<object[]>}
2242
2355
  */
@@ -2381,6 +2494,9 @@ class Table {
2381
2494
  }
2382
2495
  return result;
2383
2496
  }
2497
+ getFormulaExamples(typename) {
2498
+ return (0, table_helper_1.get_formula_examples)(typename, this.fields.filter((f) => !f.calculated));
2499
+ }
2384
2500
  }
2385
2501
  module.exports = Table;
2386
2502
  //# sourceMappingURL=table.js.map