Select column aliases
Use customName:columnName to rename Athena.js response fields without changing the underlying database columns.
Athena.js column lists support response aliases directly in the columns argument.
Use this when the application-facing payload should use different names than the storage column names.
Core syntax
The alias form is:
customName:columnNameExample:
const { data } = await athena
.from("users")
.select("user_id:id, user_email:email, createdAt:created_at");That lets the response keep app-facing names without adding a second mapping layer after the query.
String and array forms
The common form is one comma-separated string:
const result = await athena
.from("users")
.select("user_id:id, user_email:email, user_name:name");The same alias tokens also work in array form:
const result = await athena
.from("users")
.select(["user_id:id", "user_email:email", "createdAt:created_at"]);You can mix aliased and unaliased fields in the same list.
Qualified references
Aliases can target qualified column references when the query needs them:
const result = await athena
.from("public.users")
.select("user_id:public.users.id, user_email:public.users.email");This is useful when you need schema-qualified or table-qualified tokens in the select expression.
Where aliases work
Athena.js reuses the same column-list contract in several places:
.from(...).select(...).single(...).maybeSingle(...)- mutation
.select(...) - mutation
.returning(...) .rpc(...).select(...)
Examples:
await athena.from("users").insert({ email: "a@b.com" }).select("user_id:id, user_email:email");
await athena.from("users").eq("id", "u_1").single("user_id:id, user_email:email");
await athena.rpc("list_users").select("user_id:id, user_email:email");Relation to SQL AS
Athena.js also preserves simple SQL-style aliases when you pass them through directly:
await athena.from("users").select("id as user_id, email as user_email");For SDK-level examples, prefer customName:columnName because it is shorter and maps directly to the Athena.js column token contract.
When not to use this
Use the alias form for straightforward field renames.
If you need computed expressions, function calls, or more complex projections, pass the raw SQL expression you actually want:
await athena
.from("users")
.select("concat(first_name, ' ', last_name) as full_name, email");Practical guidance
- Keep alias names stable at the API or UI boundary
- Use aliases to shape the response, not to hide schema confusion
- Prefer typed model contracts for storage truth, then alias at the query edge when the consumer needs different field names