MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / executeQuery

Method executeQuery

packages/libsql/src/LibSqlDialect.ts:49–77  ·  view source on GitHub ↗
(compiledQuery: any)

Source from the content-addressed store, hash-verified

47 }
48
49 async executeQuery<R>(compiledQuery: any): Promise<QueryResult<R>> {
50 const { sql, parameters } = compiledQuery;
51 const stmt = this.#db.prepare(sql);
52
53 if (stmt.reader) {
54 return {
55 rows: stmt.all(parameters) as R[],
56 };
57 }
58
59 const query = sql.trim().toLowerCase();
60
61 /* v8 ignore next */
62 if (
63 query.startsWith('select') ||
64 ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning '))
65 ) {
66 return {
67 rows: stmt.all(parameters) as R[],
68 };
69 }
70
71 const { changes, lastInsertRowid } = stmt.run(parameters);
72 return {
73 numAffectedRows: changes as any,
74 insertId: lastInsertRowid as any,
75 rows: [],
76 };
77 }
78
79 async *streamQuery<R>(compiledQuery: any): AsyncIterableIterator<QueryResult<R>> {
80 const { sql, parameters } = compiledQuery;

Callers 6

executeMethod · 0.45
executeDumpMethod · 0.45
executeSelectFunction · 0.45
executeSelectFunction · 0.45

Calls 2

prepareMethod · 0.80
runMethod · 0.65

Tested by 2

executeSelectFunction · 0.36
executeSelectFunction · 0.36