3 ms·
There are some non-trivial examples of read and update queries in the test: https://github.com/losfair/RefineDB/blob/main/rdb-analyzer/src/data/treewalker/asm/a
by losfair 5y ago
There are some non-trivial examples of read and update queries in the test: https://github.com/losfair/RefineDB/blob/main/rdb-analyzer/src/data/treewalker/asm/asm_test.rs 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/ddac0d35b16c01105ddbe65f2b3605713fde4be4/rdb-analyzer/src/data/treewalker/asm/asm_test.rs#L392 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).