DatalogUI Demo

node v10.24.1
version: master
endpointsharetweet
const datalog = require('@datalogui/datalog') const People = datalog.newTable({ id: datalog.NumberType, name: datalog.StringType, })
// Add some data People.assert({id: 0, name: "Alice"}) People.assert({id: 1, name: "Charles"}) People.assert({id: 2, name: "Helen"})
// Define a new table for the ParentOf Relation const ParentOf = datalog.newTable({ parentID: datalog.NumberType, childID: datalog.NumberType, }) ParentOf.assert({parentID: 1, childID: 0}) ParentOf.assert({parentID: 2, childID: 0})
const Query = datalog.query(({parentName, parentID, childID}) => { People({name: "Alice", id: childID}) ParentOf({childID, parentID}) People({id: parentID, name: parentName}) })
Query.view().readAllData()
Now what if we wanted to query that data?
// Give me the ID of anyone named "Helen" from the query above. const QueryQuery = datalog.query(({parentID}) => { Query({parentID, parentName: "Helen"}) }) QueryQuery.view().readAllData()
Loading…

no comments

    sign in to comment