Skip to content

Commit 3b35f84

Browse files
committed
contacts: example script to create a new group
1 parent 6040f7a commit 3b35f84

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
let addressBookUri =
11+
"http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/index.ttl#this";
12+
13+
const groupName = faker.company.name();
14+
15+
const uri = await contacts.createNewGroup({
16+
addressBookUri,
17+
groupName,
18+
});
19+
console.log("created group:", groupName, "at", uri);
20+
21+
const result = await contacts.readAddressBook(addressBookUri);
22+
console.log("the updated address book:", result);

0 commit comments

Comments
 (0)