OptimaDB provides a type-safe, ergonomic API for reading data from your tables. The OptimaTB class exposes methods like GetOne
and Get
for querying, and supports advanced features such as filtering, sorting, limiting, and joining related data via Extend
.
Use the GetOne
method to fetch a single record by its primary key or any unique field. This method is available on every OptimaTB
instance.
typescript
1
2
Use the Get
method to fetch multiple records matching your criteria. You can filter, sort, and limit results. The return value is always an array of records.
typescript
1
2
Get
supports advanced options for filtering, sorting, and limiting results. Filtering supports operators like $eq
, $gt
, $in
, and more. Sorting and limiting are provided via the OrderBy
and Limit
options.
typescript
1
2
3
4
5
The Extend
option allows you to automatically join related data from other tables. This leverages OptimaDB's relationship tracking and is fully type-safe. The joined data is returned under a $[TableName]
property.
typescript
1
2
3
4
5
6
Under the hood, Get
and GetOne
build SQL queries using your filter objects, and Extend
triggers additional queries to fetch related data based on relationships defined in your schema. All type checking and value formatting is handled automatically.
typescript
1
2
3
4
5
6
7
Extend
.With OptimaDB, reading data is concise, robust, and type-safe. The OptimaTB
API abstracts away SQL and lets you focus on your application logic.