page
Pagination with ordering
rel.page([[:name, :asc]], 1, page_size: 10)Retrieves a specific page of results with consistent ordering. Useful for building paginated APIs.
This page documents operators that are currently available in only one of the Bmg implementations, along with suggestions for potential cross-implementation alignment.
The following operators are available in Bmg (Ruby) but not yet in Bmg.js (TypeScript):
page
Pagination with ordering
rel.page([[:name, :asc]], 1, page_size: 10)Retrieves a specific page of results with consistent ordering. Useful for building paginated APIs.
rxmatch
Regex match restriction
rel.rxmatch(:name, /^S/)Filter tuples where an attribute matches a regular expression pattern.
autosummarize
Automatic summarization
rel.autosummarize([:group_key], :sum)Automatically summarizes all non-key numeric attributes using the specified aggregator.
undress
Convert to scalars
rel.undressConverts single-attribute tuples to scalar values.
images
Multiple image shortcut
rel.images(other1, other2, ...)Shortcut for applying multiple image operations in sequence.
generator
Sequence generation
Bmg.generate(1, 100)Creates a relation from a sequence of values, similar to PostgreSQL’s generate_series.
The following operators are available in Bmg.js (TypeScript) but not yet in Bmg (Ruby):
intersect
Set intersection
left.intersect(right)Returns tuples that exist in both relations.
wrap
Wrap attributes
rel.wrap(['a', 'b'], 'nested')Combines multiple attributes into a single tuple-valued attribute.
one
Extract single tuple
rel.one()Extracts a single tuple, throwing if not exactly one exists.
isEqual
Set equality check
rel1.isEqual(rel2)Checks if two relations contain the same tuples.
These would provide the most value if implemented in both libraries:
| Operator | Missing from | Rationale |
|---|---|---|
intersect | Ruby | Common set operation, completes the set algebra |
wrap | Ruby | Inverse of unwrap, needed for structural completeness |
page | TypeScript | Essential for building paginated APIs |
| Operator | Missing from | Rationale |
|---|---|---|
one | Ruby | Useful for extracting single results safely |
isEqual | Ruby | Valuable for testing and assertions |
rxmatch | TypeScript | Useful for pattern-based filtering |
to_a (Ruby) and toArray() (TypeScript) serve the same purposey_by_x (Ruby) and yByX (TypeScript) serve the same purposeautosummarize and undress are Ruby-specific conveniences that may not fit TypeScript’s design philosophyContributions to align the libraries are welcome! See the respective repositories: