Skip to content

A lightweight hexastore implementation, uzing Redis sorted sets. Work in progress.

License

Notifications You must be signed in to change notification settings

ClaudiuCeia/redis-hexastore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redis-hexastore

A lightweight hexastore implementation, uzing Redis sorted sets. It allows storing graphs as triples (subject, predicate, object) and querying them in an efficient manner.

Example

const hexastore = await Hexastore.get(
  {
    hostname: "127.0.0.1",
    port: 6379,
  },
  {
    name: "example",
  },
);

await hexastore.batchSave([
  {
    subject: "Adrian",
    predicate: "lives",
    object: "Romania",
  },
  {
    subject: "Ana",
    predicate: "lives",
    object: "Germany",
  },
  {
    subject: "Erika",
    predicate: "lives",
    object: "Germany",
  },
  {
    subject: "Adrian",
    predicate: "likes",
    object: "beer",
  },
  {
    subject: "Ana",
    predicate: "likes",
    object: "beer",
  },
]);

const germans = await hexastore.query({
  predicate: "lives",
  object: "Germany",
});

/**
   [{
    subject: "Ana",
    predicate: "lives",
    object: "Germany",
   },
   {
    subject: "Erika",
    predicate: "lives",
    object: "Germany",
   }]
*/

const beerLikers = await hexastore.query({
  predicate: "likes",
  object: "beer",
});

/**
  [
    {
      object: "beer",
      predicate: "likes",
      subject: "Adrian",
    },
    {
      object: "beer",
      predicate: "likes",
      subject: "Ana",
    },
  ]
*/

hexastore.close();

License

MIT © Claudiu Ceia

About

A lightweight hexastore implementation, uzing Redis sorted sets. Work in progress.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published