(values: Values | Values[])
| 444 | static async create(values: Values): Promise<Model>; |
| 445 | static async create(values: Values[]): Promise<Model[]>; |
| 446 | static async create(values: Values | Values[]) { |
| 447 | const insertions = Array.isArray(values) ? values : [values]; |
| 448 | |
| 449 | const results = await this._runQuery( |
| 450 | this._currentQuery.table(this.table).create( |
| 451 | insertions.map((field) => |
| 452 | this.formatFieldToDatabase(this._wrapValuesWithDefaults(field)) |
| 453 | ) as Values[], |
| 454 | ).toDescription(), |
| 455 | ); |
| 456 | |
| 457 | if (!Array.isArray(values) && Array.isArray(results)) { |
| 458 | return results[0]; |
| 459 | } |
| 460 | |
| 461 | return results; |
| 462 | } |
| 463 | |
| 464 | /** Find one or multiple records based on the model primary key. |
| 465 | * |
no test coverage detected