MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / executeQuery

Method executeQuery

services/db-proxy/src/app-db-do.ts:95–120  ·  view source on GitHub ↗
(sqlText: string, params: unknown[], method: QueryMethod)

Source from the content-addressed store, hash-verified

93 }
94
95 executeQuery(sqlText: string, params: unknown[], method: QueryMethod): QuerySuccessResponse {
96 const cursor = this.ctx.storage.sql.exec(sqlText, ...params);
97
98 switch (method) {
99 case 'get': {
100 const rows = cursor.toArray();
101 if (rows.length === 0) {
102 return { rows: [] };
103 }
104 return { rows: Object.values(rows[0] as Record<string, unknown>) };
105 }
106 case 'all': {
107 const rows = cursor.toArray();
108 const valueRows = rows.map(row => Object.values(row as Record<string, unknown>));
109 return { rows: valueRows };
110 }
111 case 'run': {
112 return { rows: [] };
113 }
114 case 'values': {
115 const rows = cursor.toArray();
116 const valueRows = rows.map(row => Object.values(row as Record<string, unknown>));
117 return { rows: valueRows };
118 }
119 }
120 }
121
122 /**
123 * Execute a batch of queries in a transaction

Callers 2

executeBatchMethod · 0.95
runtime.tsFile · 0.80

Calls 3

toArrayMethod · 0.80
execMethod · 0.65
valuesMethod · 0.65

Tested by

no test coverage detected