Class

RamStatement

RamStatement(adapter)

Constructor

# 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

View Source ram/RamStatement.ts, line 7

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

View Source ram/RamStatement.ts, line 370

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

View Source ram/RamStatement.ts, line 44

A comparator function for sorting model instances

function

# protected 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

sequenceDiagram participant Caller participant RamStatement participant SimpleCondition participant ComplexCondition Caller->>RamStatement: parseCondition(condition) alt Simple condition (eq, gt, lt, etc.) RamStatement->>SimpleCondition: Extract attr1, operator, comparison SimpleCondition-->>RamStatement: Return predicate function else Logical operator (AND, OR) RamStatement->>ComplexCondition: Extract nested conditions RamStatement->>RamStatement: parseCondition(leftCondition) RamStatement->>RamStatement: parseCondition(rightCondition) ComplexCondition-->>RamStatement: Combine predicates with logical operator end RamStatement-->>Caller: Return query with where predicate
Parameters:
Name Type Description
condition Condition.<M>

The condition to parse

View Source ram/RamStatement.ts, line 400

A RAM query object with a where predicate function

RawRamQuery.<M>