MCPcopy Create free account
hub / github.com/damms005/devdb-vscode / getRows

Method getRows

src/database-engines/sqlite-engine.ts:290–324  ·  view source on GitHub ↗
(table: string, columns: Column[], limit: number, offset: number, whereClause?: Record<string, any>)

Source from the content-addressed store, hash-verified

288 }
289
290 async getRows(table: string, columns: Column[], limit: number, offset: number, whereClause?: Record<string, any>): Promise<QueryResponse | undefined> {
291 try {
292 const db = this.getConnection();
293 if (!db) {
294 return Promise.reject('Cannot connect to database')
295 }
296
297 const columnNames = columns.map(col => this.escapeIdentifier(col.name)).join(', ');
298 let query = `SELECT ${columnNames} FROM ${this.escapeIdentifier(table)}`;
299 const params: any[] = [];
300
301 if (whereClause && Object.keys(whereClause).length > 0) {
302 const { whereString, whereParams } = this.buildWhereClause(whereClause, columns);
303 query += whereString.trim() ? ` WHERE ${whereString}` : '';
304 params.push(...whereParams);
305 }
306
307 query += ` LIMIT ? OFFSET ?`;
308 params.push(limit, offset);
309
310 return new Promise<QueryResponse | undefined>((resolve, reject) => {
311 db.all(query, params, (err, rows: any[]) => {
312 if (err) {
313 reportError(`SQLite get rows error: ${err}`);
314 reject(err);
315 return;
316 }
317
318 resolve({ rows, sql: query });
319 });
320 });
321 } catch (err) {
322 reportError(`SQLite get rows error: ${err}`);
323 }
324 }
325
326 async getVersion(): Promise<string> {
327 try {

Callers

nothing calls this directly

Calls 4

getConnectionMethod · 0.95
escapeIdentifierMethod · 0.95
buildWhereClauseMethod · 0.95
reportErrorFunction · 0.90

Tested by

no test coverage detected