Skip to content

Commit e6079a9

Browse files
committed
contacts: example script to add contact to a group
1 parent 7fdd52b commit e6079a9

6 files changed

Lines changed: 43 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<#this>
2+
<http://www.w3.org/2006/vcard/ns#fn> "Schamberger, Quitzon and Reynolds" ;
3+
a <http://www.w3.org/2006/vcard/ns#Group> ;
4+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<#this> <http://www.w3.org/2006/vcard/ns#fn> "Becker - Smitham";
2+
a <http://www.w3.org/2006/vcard/ns#Group>;
3+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<#this> <http://www.w3.org/2006/vcard/ns#fn> "Dennis Cummings";
2+
a <http://www.w3.org/2006/vcard/ns#Individual>.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/index.ttl#this>
2+
<http://www.w3.org/2006/vcard/ns#includesGroup>
3+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Group/41faaf6f-37c3-437a-900d-e6a0e6c92463/index.ttl#this>,
4+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Group/893dba2a-2bc7-49d6-a4d2-7b89d88874ca/index.ttl#this> .
5+
6+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Group/41faaf6f-37c3-437a-900d-e6a0e6c92463/index.ttl#this>
7+
<http://www.w3.org/2006/vcard/ns#fn> "Schamberger, Quitzon and Reynolds" .
8+
9+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Group/893dba2a-2bc7-49d6-a4d2-7b89d88874ca/index.ttl#this>
10+
<http://www.w3.org/2006/vcard/ns#fn> "Becker - Smitham" .
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Person/854486c1-504a-4e11-9fe4-6d6250f08dfe/index.ttl#this>
2+
<http://www.w3.org/2006/vcard/ns#fn> "Dennis Cummings" ;
3+
<http://www.w3.org/2006/vcard/ns#inAddressBook>
4+
<http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/index.ttl#this> .
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {ContactsModuleRdfLib as ContactsModule} from '../dist/index.js';
2+
import {Fetcher, graph, UpdateManager} from "rdflib";
3+
import {faker} from "@faker-js/faker";
4+
5+
const store = graph();
6+
const fetcher = new Fetcher(store);
7+
const updater = new UpdateManager(store);
8+
const contacts = new ContactsModule({store, fetcher, updater});
9+
10+
const contactUri = "http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Person/854486c1-504a-4e11-9fe4-6d6250f08dfe/index.ttl#this";
11+
const groupUri = "http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/Group/41faaf6f-37c3-437a-900d-e6a0e6c92463/index.ttl#this";
12+
13+
await contacts.addContactToGroup({
14+
contactUri,
15+
groupUri,
16+
});
17+
console.log("added contact", contactUri, "to group", groupUri);
18+
19+
const result = await contacts.readGroup(groupUri);
20+
console.log("the updated group:", result);

0 commit comments

Comments
 (0)