Mammoth
Search…
Mammoth
A type-safe query builder pur sang
  • Type-safe query builder—sticking as close to SQL as possible
  • BYOCP (bring your own connection pool)
  • Supports Postgres only
  • Excellent autocomplete
  • Train_case to camelCase and vice versa conversion
  • Auto-migration generation based on your schema changes
1
db.with(
2
`regionalSales`,
3
() =>
4
db
5
.select(db.orderLog.region, sum(db.orderLog.amount).as(`totalSales`))
6
.from(db.orderLog)
7
.groupBy(db.orderLog.region),
8
`topRegions`,
9
({ regionalSales }) =>
10
db
11
.select(regionalSales.region)
12
.from(regionalSales)
13
.where(
14
regionalSales.totalSales.gt(
15
db.select(sum(regionalSales.totalSales).divide(10)).from(regionalSales),
16
),
17
),
18
({ topRegions }) =>
19
db
20
.select(
21
db.orderLog.region,
22
db.orderLog.product,
23
sum(db.orderLog.quantity).as(`productUnits`),
24
sum(db.orderLog.amount).as(`productSales`),
25
)
26
.from(db.orderLog)
27
.where(db.orderLog.region.in(db.select(topRegions.region).from(topRegions)))
28
.groupBy(db.orderLog.region, db.orderLog.product),
29
);
Copied!
The above is a crazy example what Mammoth can do. The best part is that the return type is automatically inferred. No worries you're making a mistake there. And all of this works without a build step. No need to have a file watcher running.
Mammoth consists of a couple of repositories:
Last modified 1yr ago
Copy link