# new RamStatement(adapter)
Extends the base Statement class to provide query building functionality for the RAM adapter. This class translates high-level query operations into predicates that can filter and sort in-memory data structures.
RAM-specific query statement builder
Parameters:
Name | Type | Description |
---|---|---|
adapter |
RamAdapter
|
The RAM adapter instance to use for executing queries |
Example
```typescript
// Create a statement for querying User models
const statement = new RamStatement<User, User>(ramAdapter);
// Build a query to find active users with age > 18
const results = await statement
.from(User)
.where(Condition.and(
Condition.eq('active', true),
Condition.gt('age', 18)
))
.orderBy('lastName', 'asc')
.limit(10)
.execute();
```
Methods
# protected build() → {RawRamQuery.<M>}
Converts the statement's selectors and conditions into a RawRamQuery object that can be executed by the RAM adapter. This method assembles all query components (select, from, where, limit, offset, sort) into the final query structure.
Builds a RAM query from the statement
The constructed RAM query object
RawRamQuery.<M>
# getSort() → {function}
Generates a function that compares two model instances based on the orderBy criteria. This method handles different data types (string, number, date) and sort directions (asc, desc).
Creates a sort comparator function
A comparator function for sorting model instances
function
# async paginate(size) → {Promise.<Paginator.<M, R, RawRamQuery.<M>>>}
Builds the query and wraps it in a RamPaginator to enable pagination of results. This allows retrieving large result sets in smaller chunks.
Creates a paginator for the query
Parameters:
Name | Type | Description |
---|---|---|
size |
number
|
The page size (number of results per page) |
A promise that resolves to a paginator for the query
Promise.<Paginator.<M, R, RawRamQuery.<M>>>
# parseCondition(condition) → {RawRamQuery.<M>}
Converts a Condition object into a predicate function that can be used to filter model instances in memory. This method handles both simple conditions (equals, greater than, etc.) and complex conditions with logical operators (AND, OR).
Parses a condition into a RAM query predicate
Parameters:
Name | Type | Description |
---|---|---|
condition |
Condition.<M>
|
The condition to parse |
A RAM query object with a where predicate function
RawRamQuery.<M>