Skip to content

Commit

Permalink
feat: Allow querying metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Jan 6, 2021
1 parent f9a2079 commit 3b63786
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ldp/representation/RepresentationMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ export class RepresentationMetadata {
}

/**
* @returns All metadata quads.
* @returns All matching metadata quads.
*/
public quads(): Quad[] {
return this.store.getQuads(null, null, null, null);
public quads(
subject: Term | null = null,
predicate: Term | null = null,
object: Term | null = null,
graph: Term | null = null,
): Quad[] {
return this.store.getQuads(subject, predicate, object, graph);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions test/unit/ldp/representation/RepresentationMetadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ describe('A RepresentationMetadata', (): void => {
expect(metadata.quads()).toBeRdfIsomorphic(inputQuads);
});

it('can query quads.', async(): Promise<void> => {
expect(metadata.quads(null, namedNode('has'), null)).toHaveLength(3);
expect(metadata.quads(null, null, literal('otherData'))).toHaveLength(2);
});

it('can change the stored identifier.', async(): Promise<void> => {
const newIdentifier = namedNode('newNode');
metadata.identifier = newIdentifier;
Expand Down

0 comments on commit 3b63786

Please sign in to comment.