has anyone managed to get drizzle to work with tauri sql plugin?

i believe they are using sqlx and I am not sure if it's the same as sqlite, I am currently working with this example I got off github
export const getDrizzleClient = (sqlite: SqliteClient) => {
return drizzle<typeof schema>(
async (sql, params, method) => {
let rows: any = [];
let results = [];

// If the query is a SELECT, use the select method
if (isSelectQuery(sql)) {
rows = await sqlite.select(sql, params).catch((e) => {
console.error("SQL Error:", e);
return [];
});
} else {
// Otherwise, use the execute method
rows = await sqlite.execute(sql, params).catch((e) => {
console.error("SQL Error:", e);
return [];
});
return { rows: [] };
}

rows = rows.map((row: any) => {
return Object.values(row);
});

// If the method is "all", return all rows
results = method === "all" ? rows : rows[0];

return { rows: results };
},
// Pass the schema to the drizzle instance
{ schema: schema, logger: true }
);
};
export const getDrizzleClient = (sqlite: SqliteClient) => {
return drizzle<typeof schema>(
async (sql, params, method) => {
let rows: any = [];
let results = [];

// If the query is a SELECT, use the select method
if (isSelectQuery(sql)) {
rows = await sqlite.select(sql, params).catch((e) => {
console.error("SQL Error:", e);
return [];
});
} else {
// Otherwise, use the execute method
rows = await sqlite.execute(sql, params).catch((e) => {
console.error("SQL Error:", e);
return [];
});
return { rows: [] };
}

rows = rows.map((row: any) => {
return Object.values(row);
});

// If the method is "all", return all rows
results = method === "all" ? rows : rows[0];

return { rows: results };
},
// Pass the schema to the drizzle instance
{ schema: schema, logger: true }
);
};
I am getting an error subRows is not defined when using the query API, is there a different adapter that might be better suited for this use case?
1 Reply
hachoter
hachoter5mo ago
Curiously this does work with regular select statements but not with RQB
Want results from more Discord servers?
Add your server