We are looking with great interest at the evolution of DGraph as it seems to be a very natural fit to our requirements. It looks like a very solid new entry in the Graph Database space.
Since we can rather easily change databases for our read-models we have no trouble testing out new database implementations. But found one limitation that limits going further.
In our system our security system relies in part on integer value set intersections. Usually we can implement that with features available in the database or using a user-defined-function.
All our data is organized in a tree (though documents in the tree can reference arbitrary other documents). Each document has an array of locks e.g [4,8,9] and also a set of inherited locks from âparentâ documents [ [1,8] , [9,72] ]. When a user performs a query we basically retrieve his keys [1,9] and all results are filtered against these by intersecting each existing array of locks with the keys. A non-empty intersection results in inclusion in the result-set.
The actual operation is very cheap. Since the arrays are usually not very big calculating intersections of these integers is easy.
[ [1,8], [9,72], [4,8,9] ] INTERSECT EACH [1,9] => [ [1], [9], [9] ] => PASS
[ [1,8], [9,72], [4,8,9] ] INTERSECT EACH [9] => [ [], [9], [9] ] => FAIL
I am unsure how we could model this requirement given the existing filtering abilities without resorting to client side filtering again.
Optimally I would like to store the locks and inherited locks in one string object (or typed as a multidimensional integer array) and have a filter similar to a geo filter (the exact syntax is not relevant here and should be given some more thought of course).
{
debug(intersect("all_locks", "{'test':'all_non_empty', 'test': [1,9]}" ) ) {
type.object.name.en: name
}
}
Simple set operations like these would offer a lot of value in a number of scenarios we have encountered of the years.
Does anybody know whether this could be implemented or can somebody offer an alternate in the current state of DGraph ?