News for hackers. Stuff that matters.
Re:Show HN: A strongly-typed document DB that runs on any tr... by losfair on Monday August 30, 2021 @08:30AM (#28354938)
There are some non-trivial examples of read and update queries in the test: https://github.com/losfair/RefineDB/blob/main/rdb-analyzer/s...

For example, here's a test that generates a list of integers, inserts the list into the database as set members, computes the sum and verifies it, and reads back the list: https://github.com/losfair/RefineDB/blob/ddac0d35b16c01105dd... . The read-back part looks like:

  // Schema
  /*
    type Store {
      collection_a: set<Number>,
      collection_b: set<Number>,
    }
    type Number {
      @primary
      value: int64,
    }
    export Store store;
  */
    graph main(root: schema): map {
      list1: list<int64>,
      list2: list<int64>,
    } {
      list1 = reduce(decompose_numbers) create_map create_list(int64) root.store.collection_a;
      list2 = reduce(decompose_numbers) create_map create_list(int64) root.store.collection_b;
      return m_insert(list1) list1
        $ m_insert(list2) list2
        create_map;
    }
    graph decompose_numbers(_unused: map{}, current: list<int64>, v: Number): list<int64> {
      return v.value : current;
    }

And it's trivial to modify the reduce function `decompose_numbers` to return a more interesting aggregated value, e.g. the sum.

The syntax is not yet very optimized for humans though (hence the name RefineAsm).

There are no comments on this comment yet.