Public API available via import { ... } from '@enspirit/bmg-js'.
| Export | Description |
|---|---|
Bmg(tuples) |
Factory to create relations from arrays |
Bmg.isRelation(value) |
Type guard for relations |
DEE |
Relation with no attributes, one tuple (identity for join) |
DUM |
Relation with no attributes, no tuples (identity for union) |
LIB_DEFINITIONS |
TypeScript definitions string (for playgrounds) |
| Export | Description |
|---|---|
toText(input, options?) |
Render relation/tuple as ASCII table |
isRelation(value) |
Type guard for relations |
isEqual(left, right) |
Check set equality of two relations |
All operators work on arrays and return arrays:
| Category | Operators |
|---|---|
| Filtering | restrict, where, exclude |
| Projection | project, allbut |
| Extension | extend, constants |
| Renaming | rename, prefix, suffix |
| Set ops | union, minus, intersect |
| Semi-joins | matching, not_matching |
| Joins | join, left_join, cross_product |
| Nesting | group, ungroup, wrap, unwrap, image, summarize, autowrap |
| Transform | transform |
| Terminal | one, yByX |
All operators above are also available as chainable methods on relations:
const result = Bmg(suppliers)
.restrict({ city: 'London' })
.project(['sid', 'name'])
.toArray();Additional methods on Relation<T>:
toArray()- Get all tuples as arraytoText(options?)- ASCII table representationisEqual(other)- Set equality checkcross_join(other)- Alias forcross_product
Core: Tuple, AttrName, Relation, RelationOperand
Predicates: Predicate, TypedPredicate
Extensions: Extension, TypedExtension
Joins: JoinKeys, TypedJoinKeysArray, TypedJoinKeysObject
Aggregation: Aggregator, Aggregators, AggregatorName, AggregatorSpec
Options: TextOptions, AutowrapOptions, PrefixOptions, SuffixOptions, GroupOptions, WrapOptions
Utility types: Renamed, Prefixed, Suffixed, Joined, LeftJoined, Wrapped, Unwrapped, Ungrouped, CommonKeys