@faubulous/mentor-rdf
    Preparing search index...

    Class Store

    Implements

    • DatasetCore<rdfjs.Quad>
    Index
    reasoner?: Reasoner

    The reasoner to be used for inference.

    • get dataFactory(): DataFactory

      Get the RDF.js DataFactory used by the store.

      Returns DataFactory

    • get size(): number

      Get the number of triples in all graphs of the store.

      Returns number

    • get version(): number

      Get a monotonic counter that is incremented on every mutation of the store. Can be used to cheaply detect whether the store has changed.

      Returns number

    • Returns Iterator<Quad, any, any>

    • Add a quad to the store. Existing quads with the same subject, predicate, object, and graph will be ignored.

      Parameters

      • quad: Quad

        The quad to be added.

      Returns this

      The store instance.

    • Indicate if there are triples matching the given pattern in the store.

      Parameters

      • graphUris: string | string[] | undefined

        Optional graph URI or array of graph URIs to query.

      • subject: Quad_Subject | null

        A subject URI or null to match any subject.

      • predicate: Quad_Predicate | null

        A predicate URI or null to match any predicate.

      • object: Quad_Object | null

        An object URI or null to match any object.

      • OptionalincludeInferred: boolean

      Returns boolean

      true if there are triples matching the pattern, false otherwise.

    • Get an RDF/JS Source interface for the store that streams matching quads. Primarily intended for query engines such as Comunica that operate on quad streams.

      Returns Source<Quad>

      A source that returns a stream of quads for a given pattern.

    • Removes every quad from the store and releases the memory of the underlying store, including its term dictionary, which never shrinks when quads are deleted. The version counters keep increasing so that cached views and validators notice the change.

      Returns void

    • Returns the exact cardinality of the quads matching the pattern.

      Parameters

      • Optionalsubject: Term | null

        The optional subject.

      • Optionalpredicate: Term | null

        The optional predicate.

      • Optionalobject: Term | null

        The optional object.

      • Optionalgraph: Term | null

        The optional graph.

      Returns number

    • Delete a quad from the store.

      Parameters

      • quad: Quad

        The quad to be deleted.

      Returns this

      The store instance.

    • Delete named graphs from the store.

      Parameters

      • graphUris: string[]

        URIs of the graphs to be deleted; an empty string denotes the default graph.

      • includeInferred: boolean = false

        Whether to also delete the inference graph of each graph, as named by the reasoner's target URI generator. Ignored when the store has no reasoner.

      Returns void

    • Apply inference to the given graph and store the triples in the associated inference graph.

      Parameters

      • graphUri: string | Quad_Graph

        A graph URI.

      Returns void

    • Get the first triple matching the given pattern in the store.

      Parameters

      • graphUris: string | string[] | undefined

        Optional graph URI or array of graph URIs to query.

      • subject: Quad_Subject | null

        A subject URI or null to match any subject.

      • predicate: Quad_Predicate | null

        A predicate URI or null to match any predicate.

      • object: Quad_Object | null

        An object URI or null to match any object.

      • OptionalincludeInferred: boolean

      Returns Quad

      The first triple that matches the pattern.

      If no triple is found matching the pattern.

    • Get a read-only DatasetCore view of all quads in the specified graphs. The view is lazy and live: it reflects the current contents of the store without copying any quads. If you need an immutable snapshot, copy the view into a new dataset, e.g. RdfStore.createDefault().asDataset().

      Parameters

      • OptionalgraphUris: string | string[]

        Optional graph URI or array of graph URIs. If undefined, all graphs are included.

      • OptionalincludeInferred: boolean

        Whether to include inferred triples. If undefined, inferred triples are included when a reasoner is available. If false, the inference graphs of the given graphs are left out, or, without graphs, every inference graph of the store. If true without a reasoner, an error is thrown.

      Returns DatasetView

      A read-only dataset view of the matching quads.

    • Get the URIs of the graphs in the triple store.

      Returns string[]

      An array of graph URIs in no particular order.

      Every mutation of the store records the graph it touched, so the graphs are the recorded ones that still hold a triple. Matching all triples instead would copy the whole store, which takes seconds for a store holding a large workspace.

    • Get a monotonic counter for a single graph, incremented on every mutation of the graph. Can be used to cheaply detect whether the contents of a graph have changed.

      Parameters

      • graphUri: string

        A graph URI.

      Returns number

      The current version of the graph; 0 if the graph was never modified.

    • Get the URIs of ordered list members in the store.

      Parameters

      • graphUris: string | string[] | undefined

        Optional graph URI or array of graph URIs to query.

      • listUri: string

        URI of the list to get the items from.

      Returns string[]

      An array of URIs of the items in the list.

    • Indicates if the store contains a specific quad.

      Parameters

      • quad: Quad

        The quad to be checked.

      Returns boolean

      true if the quad is found in the store, false otherwise.

    • Indicates if the store contains triples in a given graph.

      Parameters

      • graphUri: string | Quad_Graph

        A graph URI.

      Returns boolean

      true if the store contains triples in the graph URI, false otherwise.

    • Indicates whether a graph holds the triples the reasoner inferred from another graph.

      Parameters

      • graph: string | Quad_Graph

        A graph term or URI.

      Returns boolean

      true if the graph is an inference graph of the reasoner of this store, false otherwise or without a reasoner.

    • Indicates whether a quad was inferred by the reasoner, i.e. whether it is stored in an inference graph. A triple that is asserted and inferred exists as two quads; only the quad in the inference graph is inferred.

      Parameters

      • quad: Quad

        A quad.

      Returns boolean

      true if the quad is stored in an inference graph, false otherwise.

    • Loads a set of W3C Standard ontologies into the store (RDF, RDFA, RDFS, OWL, SKOS, SHACL, XSD) and the SPARQL Syntax Vocabulary.

      Parameters

      • executeInference: boolean = true

      Returns Promise<void>

      The ontology sources embedded in this package will be removed in the next major release. Import the published Turtle files instead (e.g. @faubulous/mentor-rdf/ontologies/rdfs.ttl) and load them with loadTurtle.

    • Create an RDF store from RDF/XML data.

      Parameters

      • input: string | EventEmitter<any>

        Input data or stream format to be parsed.

      • graphUri: string

        URI of the graph to in which the triples will be created.

      • executeInference: boolean = true

        Indicates if inference should be executed after loading the triples.

      • clearGraph: boolean = true

        Indicates if the graph should be cleared before loading.

      • OptionalonQuad: (quad: Quad) => void

        Callback function that will be called for each parsed triple.

      Returns Promise<Store>

      A promise that resolves to an RDF store.

    • Create an RDF store from N-Quads data.

      Parameters

      • input: string

        Input string in N-Quads format.

      • graphUri: string

        URI of the default graph to use when quads have no graph component.

      • executeInference: boolean = true

        Indicates if inference should be executed after loading the triples.

      • clearGraph: boolean = true

        Indicates if the graph should be cleared before loading.

      • OptionalonQuad: (quad: Quad) => void

        Callback function that will be called for each parsed triple.

      Returns Store

      The store instance.

    • Create an RDF store from Turtle, N3 or N-Triples data.

      Parameters

      • input: string

        Input string in Turtle, N3 or N-Triples format.

      • graphUri: string

        URI of the graph to in which the triples will be created.

      • executeInference: boolean = true

        Indicates if inference should be executed after loading the triples.

      • clearGraph: boolean = true

        Indicates if the graph should be cleared before loading.

      • OptionalonQuad: (quad: Quad) => void

        Callback function that will be called for each parsed triple.

      Returns Store

      A promise that resolves to an RDF store.

    • Returns a lazy, read-only dataset view of the quads matching the given pattern. Implements the RDF/JS DatasetCore.match semantics: a graph names exactly that graph and no graph means every graph of the store, inference graphs included. The result reflects the current contents of the store and does not copy any quads. Because the view iterates the live indexes, do not add or delete quads while iterating it; take a snapshot with Array.from(...) first.

      Parameters

      • Optionalsubject: Term | null

        The optional subject.

      • Optionalpredicate: Term | null

        The optional predicate.

      • Optionalobject: Term | null

        The optional object.

      • Optionalgraph: Term | null

        The optional graph.

      Returns DatasetView

      A read-only dataset view of the matching quads.

    • Query the store for triples matching the given pattern supporting multiple graphs. The iterator is live: do not add or delete quads while iterating; take a snapshot with Array.from(...) first.

      Parameters

      • graphUris: string | string[] | undefined

        Optional graph URI or array of graph URIs to query.

      • subject: Quad_Subject | null

        A subject URI or null to match any subject.

      • predicate: Quad_Predicate | null

        A predicate URI or null to match any predicate.

      • object: Quad_Object | null

        An object URI or null to match any object.

      • OptionalincludeInferred: boolean

        Whether to read the inference graphs. With graphs given, undefined and true add the inference graph of each graph when a reasoner is available and false reads only the given graphs. Without graphs, undefined and true read every graph of the store and false reads every graph except the inference graphs. true without a reasoner throws.

      Returns Generator<Quad, void, any>

    • Synchronously iterate the quads matching a single pattern. The iterator is live: do not add or delete quads while iterating; take a snapshot with Array.from(...) first.

      Parameters

      • Optionalsubject: Term | null

        The optional subject.

      • Optionalpredicate: Term | null

        The optional predicate.

      • Optionalobject: Term | null

        The optional object.

      • Optionalgraph: Term | null

        The optional graph.

      Returns Generator<Quad>

    • Write the triples in the store into a string in Turtle format.

      Parameters

      • sourceGraphUri: string

        A graph URI.

      • targetFormat: string = 'text/turtle'

        Optional mime type of the serialization format (e.g., 'text/turtle').

      • OptionaltargetGraphUri: string

        Optional target graph URI. If not provided, the source graph URI will be used for serialization formats that support quads.

      • Optionalprefixes: Record<string, string>

        Optional prefixes to be used in the serialization.

      Returns Promise<string>

      A string serialization of the triples in the graph in the specified format.