59 points · by stopachka · 2y ago · 22 comments
Thanks for teaching an old dog new tricks :) Where to do from here? Any other triple-based databases out there?
EDIT: please ignore the absolutely rude and entitled sibling comment.
Datomic https://www.datomic.com
xtdb https://github.com/xtdb/xtdb
DataScript (not a database though) https://github.com/tonsky/datascript
It is interesting to know I’m “entitled” for wanting people to provide accurate information online, rather than misinforming and confusing people.
// In-memory storage for voted users const votedUsers = new Set();
// Datalog-like rules function eligible_to_vote(user) { return isUserOldEnough(user) && isCanadianCitizen(user); }
function voted(user, bill) { return votedUsers.has(`${user}_${bill}`); }
// Custom rules function isUserOldEnough(user) { // Assuming age is stored in user object return user.age >= 18; }
function isCanadianCitizen(user) { // Assuming citizenship information is stored in user object return user.citizenship === 'Canada'; }
function recordVote(user, bill) { // Record that the user has voted on the specified bill votedUsers.add(`${user}_${bill}`); }
// Example usage const user = { name: "user123", age: 25, citizenship: "Canada", };
const bill = "bill456";
if (eligible_to_vote(user)) { console.log("User is eligible to vote.");
if (!voted(user.name, bill)) {
console.log("User can vote on this bill.");
// Implement further logic for voting...
// Record the vote
recordVote(user.name, bill);
} else {
console.log("User has already voted on this bill.");
}
} else {
console.log("User is not eligible to vote.");
}Here's an __actual__ small (and very fast) full blown datalog engine: https://github.com/brurucy/micro-datalog