Could i save an array or a dictionary as a property in my pod?

for example, i want create a class schedule in my pod, the schedule contains teacher name,datetime,classroom and subject. So i want save the infomation as a dictionary,[[“teacher1”,“subject1”,{monday:[time,classroom],tuesday:[time,classroom]…}],[“teacher2”…]]
i have created a folder as schedule, and created different thing as subject,but time,classroom,week should be a group,i have no idea how to connect them.

1 Like

Hi @wenjingli-qa, I’ll be assuming you’re using @inrupt/solid-client here. If so, it does not at this time support ordered lists, but if the order does not matter, you could do something like this:

import { addStringNoLocale, addUrl, createSolidDataset, createThing, setThing } from "@inrupt/solid-client";
import { schema } from "rdf-namespaces";

let slot1 = createThing();
slot1 = addUrl(slot1, schema.dayOfWeek, "http://schema.org/Monday");

let slot2 = createThing();
slot2 = addUrl(slot2, schema.dayOfWeek, "http://schema.org/Wednesday");

let subject1 = createThing();
subject1 = addStringNoLocale(subject1, schema.name, "Transfiguration");
subject1 = addUrl(subject1, "https://your.vocab/slot", slot1);
subject1 = addUrl(subject1, "https://your.vocab/slot", slot2);

let teacher1 = createThing();
teacher1 = addStringNoLocale(teacher1, schema.name, "Minerva McGonagall");
teacher1 = addUrl(teacher1, "https://your.vocab/teaches-subject", subject1);

let newResource = createSolidDataset();
newResource = setThing(newResource, slot1);
newResource = setThing(newResource, slot2);
newResource = setThing(newResource, subject1);
newResource = setThing(newResource, teacher1);

(See this CodeSandbox.)

You’ll have to adjust the data and properties you want to use, but hopefully that gives somewhat of an idea of how to go about this. But let us know if you have further questions! :slight_smile:

1 Like

@Vincent Thanks for your replay! i have a question:what is “https://your.vocab/slot”?do i need to build a web to save my vocab?
or Are there some properites’ value can be array, and set array to properties by using @inrupt/solid-client

@Vincent i have run the code as you write,but how to get the content of slot?
add schedule

async function saveCardId(){

    let slot1 = createThing({name:'slot1'});
    slot1 = addStringNoLocale(slot1,schema.name,'test1');
    let slot2 = createThing({name:'slot2'});
    slot2 = addStringNoLocale(slot2, schema.name, 'test2');
    let subject1 = createThing({name:"subject1"});
    subject1 = addUrl(subject1, RDF.type, slot1);
    subject1 = addUrl(subject1,RDF.type, slot2);
    let myCardList  = await getSolidDataset(cardIdUrl,{fetch:fetch});
    myCardList = setThing(myCardList,subject1);
    await saveSolidDatasetAt( cardIdUrl,myCardList,  { fetch: fetch } );
}

i access my pod, i can’t get slot’s content, as follows:
image
i using the function getThing to get slot information is also failed.

async function viewCard(title) {
    const selectToCardUrl = cardIdUrl +"#"+ title;
    const linkcode1 = cardIdUrl+"#slot1";
    const linkcode2 = cardIdUrl+"#slot2";
    const myDataset = await getSolidDataset(cardIdUrl, { fetch: fetch });
    const profile = getThing(myDataset, selectToCardUrl);
    const profile1 = getThing(myDataset,linkcode1);
    const profile2 = getThing(myDataset,linkcode2);

    console.log(profile,profile1,profile2);}

Vocabularies aren’t really my speciality, but basically you’ll need a URL to identity each property. You can find an existing vocabulary, or come up with a URL yourself on a domain that you control. Technically, those URLs don’t need to resolve to anything, but it can make interoperability easier if you do.

There’s a lot more detail here: Vocabularies overview · Solid

Note that in your code snippet, you’ve only added subject to myCardList, not slot1 and slot2. I also don’t understand why you’ve set subject1's RDF.type to slot1 and slot2.

You might want to try my tool Penny to inspect your data instead, that might give you a better view of what’s actually saved to your Pod.