Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "join"

Index

Functions

Functions

Const join

  • join(xrel: Set<IObjectOf<any>>, yrel: Set<IObjectOf<any>>): Set<IObjectOf<any>>
  • Computes the natural join between the two sets of relations. Each set is assumed to have plain objects as values with at least one of the keys present in both sides. Furthermore the objects in each set are assumed to have the same internal structure (i.e. sets of keys). Returns new set of same type as xrel.

    join(
      new Set([
        {id: 1, name: "foo"},
        {id: 2, name: "bar"},
        {id: 3, name: "baz"}]),
      new Set([
        {id: 1, color: "red"},
        {id: 2, color: "blue"}])
    )
    // Set {
    //   { id: 1, color: 'red', name: 'foo' },
    //   { id: 2, color: 'blue', name: 'bar' }
    // }

    Parameters

    • xrel: Set<IObjectOf<any>>
    • yrel: Set<IObjectOf<any>>

    Returns Set<IObjectOf<any>>

Const joinWith

  • joinWith(xrel: Set<any>, yrel: Set<any>, kmap: IObjectOf<PropertyKey>): Set<any>
  • Similar to join(), computes the join between two sets of relations, using the given keys in kmap only for joining and ignoring others. kmap can also be used to translate join keys in yrel where needed. Else, if no renaming is desired, the values in kmap should be the same as their respective keys, e.g. {id: "id"}. Returns new set of same type as xrel.

    joinWith(
      new Set([
        {id: 1, name: "foo"},
        {id: 2, name: "bar"},
        {id: 3, name: "baz"}]),
      new Set([
        {type: 1, color: "red"},
        {type: 2, color: "blue"}]),
      {id: "type"}
    )
    // Set {
    //   { type: 1, color: 'red', id: 1, name: 'foo' },
    //   { type: 2, color: 'blue', id: 2, name: 'bar' } }

    Parameters

    • xrel: Set<any>
    • yrel: Set<any>
    • kmap: IObjectOf<PropertyKey>

      keys to compute join for

    Returns Set<any>

Generated using TypeDoc