Count the number of records of a model or filtered by a field name. * * await Flight.count(); * * await Flight.where("destination", "Dublin").count();
(field = "*")
| 778 | * await Flight.where("destination", "Dublin").count(); |
| 779 | */ |
| 780 | static async count(field = "*") { |
| 781 | const value = await this._runQuery( |
| 782 | this._currentQuery |
| 783 | .table(this.table) |
| 784 | .count(this.formatFieldToDatabase(field) as string) |
| 785 | .toDescription(), |
| 786 | ); |
| 787 | |
| 788 | return Number((value as AggregationResult[])[0].count); |
| 789 | } |
| 790 | |
| 791 | /** Find the minimum value of a field from all the selected records. |
| 792 | * |
no test coverage detected