Skip to content

Commit 86ee67c

Browse files
jeswrRubenVerborgh
authored andcommitted
Document DatasetCore interface.
1 parent 38afbc3 commit 86ee67c

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ Then, we find triples with `:Mickey` as subject.
282282

283283
```JavaScript
284284
const store = new N3.Store();
285-
store.addQuad(
285+
store.add(
286286
namedNode('http://ex.org/Pluto'),
287287
namedNode('http://ex.org/type'),
288288
namedNode('http://ex.org/Dog')
289289
);
290-
store.addQuad(
290+
store.add(
291291
namedNode('http://ex.org/Mickey'),
292292
namedNode('http://ex.org/type'),
293293
namedNode('http://ex.org/Mouse')
@@ -297,12 +297,25 @@ store.addQuad(
297297
for (const quad of store)
298298
console.log(quad);
299299
// Retrieve Mickey's quads
300-
for (const quad of store.readQuads(namedNode('http://ex.org/Mickey'), null, null))
300+
for (const quad of store.match(namedNode('http://ex.org/Mickey'), null, null))
301301
console.log(quad);
302302
```
303303

304+
### [`DatasetCore` Interface](https://rdf.js.org/dataset-spec/#datasetcore-interface)
305+
This store adheres to the `DatasetCore` interface which exposes the following properties
306+
307+
Attributes:
308+
- `size` — A non-negative integer that specifies the number of quads in the set.
309+
310+
Methods:
311+
- `add` — Adds the specified quad to the dataset. Existing quads, as defined in `Quad.equals`, will be ignored.
312+
- `delete` — Removes the specified quad from the dataset.
313+
- `has` — Determines whether a dataset includes a certain quad.
314+
- `match` — Returns a new dataset that is comprised of all quads in the current instance matching the given arguments.
315+
- `[Symbol.iterator]` — Implements the iterator protocol to allow iteration over all `quads` in the dataset as in the example above.
316+
304317
### Addition and deletion of quads
305-
The store provides the following manipulation methods
318+
The store provides the following manipulation methods in addition to implementing the standard [`DatasetCore` Interface](https://rdf.js.org/dataset-spec/#datasetcore-interface)
306319
([documentation](http://rdfjs.github.io/N3.js/docs/N3Store.html)):
307320
- `addQuad` to insert one quad
308321
- `addQuads` to insert an array of quads
@@ -386,6 +399,7 @@ The N3.js submodules are compatible with the following [RDF.js](http://rdf.js.or
386399
[`Store`](http://rdf.js.org/stream-spec/#store-interface)
387400
[`Source`](http://rdf.js.org/stream-spec/#source-interface)
388401
[`Sink`](http://rdf.js.org/stream-spec/#sink-interface)
402+
[`DatasetCore`](https://rdf.js.org/dataset-spec/#datasetcore-interface)
389403

390404
## License and contributions
391405
The N3.js library is copyrighted by [Ruben Verborgh](https://ruben.verborgh.org/)

0 commit comments

Comments
 (0)