I already hear you : “Urgh… another library to access data on Solid pods, rdflib, tripledoc, soukai…” and you may be right but hold on!
Right now, developing for Solid is kinda frustrating. If you’re not familiar with Linked Data (as I was), every library expecting you to use triples or quads will hurt you. This library aims to help you store data easily on a pod and take care of the repetitive stuff.
Here is an overview of the library available here https://github.com/solideal/storage :
-
Lightweight with only one dependency to
@inrupt/solid-client
- Created for Solid
- Written in Typescript
- Easily maps between triples / javascript objects without hassle
- Provides an easy API to create/update, read and delete data on a pod
- Use Solid type indexes to resolve data location if you need to (and may even register the type as needed)
Here is a sample of what you can do right now with @solideal/storage
:
import { Repository, is } from "@solideal/storage";
// Let's say you already have some data to persist
const myBookmark = {
id: "some-unique-identifier",
title: "My super duber local bookmark",
url: "http://localhost:3000",
};
// And now you want to persist it (let's assume the user has already a type registration for this type of data
// Here I'm using the `resolve` static method which means the library will look at the webid type
// index to determine where to actually store the data.
const repository = Repository<typeof myBookmark>.resolve({
type: "https://www.w3.org/2002/01/bookmark#Bookmark",
schema: {
id: is.key(), // This one is mandatory and will contains the resource location
title: is.string("http://purl.org/dc/elements/1.1/title"),
url: is.url("https://www.w3.org/2002/01/bookmark#recalls"),
},
}, {
webid: "https://yuukanoo.solid.community/profile/card#me" // needed if no global webid was defined with `configure({ webid: "..." })`
});
await repository.save(myBookmark); // myBookmark.id will equals the final url on your pod :)
I already have a lot of ideas in my head to go even further and the API may break in the future but I wanted to share what I came up with so far to see if it can help other people.
7 posts - 3 participants