Advanced Queries
@an5/adapters provides powerful query capabilities for complex data retrieval across SQL dialects (MSSQL, PostgreSQL, MySQL, SQLite) and Google Sheets.
Sqlite note: SQLite uses LIMIT/OFFSET pagination and ? placeholders in Python raw SQL. The Go example uses the sqlite3 driver name; register that driver before opening a connection.
Client query capabilities
The examples above use @an5/adapters for TypeScript. The generated clients cover
the same ground for the other languages, but not evenly — each one is generated
from the same schema and the query surface differs:
| TypeScript | Python | .NET | Go | Rust | Java | Kotlin | Swift | |
|---|---|---|---|---|---|---|---|---|
| Read rows | findMany |
find_many |
FindMany |
FindMany |
find_many |
findMany |
findMany |
findMany |
| Filter | where object |
where dict |
SQL predicate | typed structs | typed structs | An5Query.where |
query block | Query(filter:) |
| Sort | orderBy |
order_by |
in the SQL you write | *SortOrder |
SortOrder |
An5Query.orderBy |
orderBy(...) |
Query.orderBy |
| Paginate | skip / take |
skip / take |
in the SQL you write | Skip / Take |
skip / take |
skip / take |
skip / take |
skip / take |
| Select columns | select |
select |
— | Select |
select |
select |
select |
select |
| Load relations | include |
include |
— | — | — | include |
include |
include |
| Aggregate | aggregate |
aggregate |
Count only |
— | through table() |
aggregate |
aggregate |
aggregate |
| Group by | groupBy |
group_by |
— | — | through table() |
groupBy |
groupBy |
groupBy |
| Raw SQL | $queryRawUnsafe |
query_raw |
QueryRaw |
QueryRaw |
adapter().query_raw |
queryRaw |
query |
query |
The examples below use the fields of the generated example schema — User with
id, email, name, createdAt, and Order with userId, total — so the
queries line up across languages.
.NET (C#)
The generated .NET client takes a SQL predicate, not a filter object, and has
no orderBy, select, or relation loading — sorting and paging are part of the
predicate you write:
using An5Orm;
using An5Orm.Entities;
var db = new An5DbContext(); // reads DATABASE_URL
var users = db.User.FindMany(
"email LIKE @email AND createdAt >= @since",
new Dictionary<string, object>
{
["email"] = "%@example.com%",
["since"] = new DateTime(2026, 1, 1),
});
// SQL Server: OFFSET/FETCH does not accept parameters, so the page numbers are
// inlined. PostgreSQL and SQLite use "LIMIT @take OFFSET @skip".
var page = db.User.FindMany(
"email LIKE @email ORDER BY createdAt DESC LIMIT 10 OFFSET 20",
new Dictionary<string, object> { ["email"] = "%@example.com%" });
var activeCount = db.User.Count("email LIKE @email",
new Dictionary<string, object> { ["email"] = "%@example.com%" });
There is no aggregate or groupBy. Count covers counting rows; anything else
goes through raw SQL:
var revenue = db.Order.QueryRaw(
"SELECT COALESCE(SUM(total), 0) AS revenue FROM orders WHERE total >= @min",
new Dictionary<string, object> { ["min"] = 10 });
The client is synchronous throughout — there is no FindManyAsync.
Next Steps
- Relations - Model relationships & nested writes
- Deployment - Production configuration