(query: QueryExp, options?: EvalQueryOptions)
| 162 | } |
| 163 | |
| 164 | async rowCount(query: QueryExp, options?: EvalQueryOptions): Promise<number> { |
| 165 | await this.ensureLeafDeps(query); |
| 166 | const countSql = query.toCountSql(this.db.dialect, this.tableMap); |
| 167 | |
| 168 | const trueOptions = options ? options : defaultEvalQueryOptions; |
| 169 | |
| 170 | if (trueOptions.showQueries) { |
| 171 | // log.info("time to generate sql: %ds %dms", t1s, t1ns / 1e6); |
| 172 | log.debug("rowCount: evaluating: \n" + countSql); |
| 173 | } |
| 174 | |
| 175 | const rows = await this.db.runSqlQuery(countSql); |
| 176 | let rowCount = rows[0].rowCount as number; |
| 177 | if (typeof rowCount === "bigint") { |
| 178 | const rcVal = rowCount as bigint; |
| 179 | rowCount = Number.parseInt(rcVal.toString()); |
| 180 | } |
| 181 | return rowCount; |
| 182 | } |
| 183 | |
| 184 | // ensure every table (or base query) mentioned in query is registered: |
| 185 | async ensureLeafDeps(query: QueryExp): Promise<void> { |
nothing calls this directly
no test coverage detected