MCPcopy
hub / github.com/antonycourtney/tad / rowCount

Method rowCount

packages/reltab/src/DataSource.ts:164–182  ·  view source on GitHub ↗
(query: QueryExp, options?: EvalQueryOptions)

Source from the content-addressed store, hash-verified

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> {

Callers

nothing calls this directly

Calls 3

ensureLeafDepsMethod · 0.95
toCountSqlMethod · 0.80
runSqlQueryMethod · 0.65

Tested by

no test coverage detected