Adds IRI prefix declarations to this dataset.
Alias-to-IRI pairs, for example { ex: "https://example.org/" }.
Creates a service that makes this dataset queryable.
Name for the service, which becomes part of its URL.
Optionalopts: NewService
Which kind to create; a SPARQL service (virtuoso) when omitted.
The service starts out empty and syncs the dataset in the background, so it cannot answer queries yet — wait with Service.waitUntilRunning.
If this dataset already has a service with that name. Use Dataset.ensureService when you want the existing one.
// `index_patterns` has to be "index" — that is what the service calls its index, and a
// template that matches nothing is silently unused.
const service = await dataset.addService("my-search", {
type: "elasticSearch",
config: {
indexTemplates: [{ name: "my-template", index_patterns: "index" }],
},
});
await service.waitUntilRunning();
// Only needed for a property whose objects are plain strings: one already typed `xsd:date`
// or `xsd:dateTime` is mapped as a date by the service, and keeps that mapping regardless of
// this template. The mapping lives in a component template, which takes effect only once an
// index template pulls it in by name. Field names are IRIs with every "." replaced by a space.
await dataset.addService("my-search", {
type: "elasticSearch",
config: {
componentTemplates: [
{
name: "dates",
template: { mappings: { properties: { "https://schema org/dateCreated": { type: "date" } } } },
},
],
indexTemplates: [{ name: "my-template", index_patterns: "index", composed_of: ["dates"] }],
},
});
ServiceConfigElastic for what an Elasticsearch service accepts, and ServiceConfigJena for the Jena reasoner.
Deletes the named resources of this dataset, leaving the dataset itself in place.
The first kind of resource to delete.
Further kinds, to clear several in one call.
Copies this dataset, with its data, to another account on the same instance.
Account to copy into. Your token must be allowed to write there.
OptionalnewDatasetName: string
Name for the copy; this dataset's name is reused when omitted.
The new dataset, not this one.
Deletes this dataset, with its graphs, assets and services.
Destructive and not undoable. Use Dataset.clear to empty a dataset you want to keep.
Deletes one named graph and its statements.
Destructive and not undoable. Resolves the graph first, so it shares Dataset.getGraph's cost and its error when the graph is absent.
The instance's description of one resource.
The resource to describe.
The description as RDF/JS quads.
The service with this name, created first if this dataset does not have one yet.
Optionalargs: NewServiceThe idempotent form of Dataset.addService. Either way the result may still be syncing, so follow it with Service.waitUntilRunning.
The asset with this name.
The asset's name, as given when it was uploaded.
OptionalversionNumber: number
Pin the result to this version; the latest is used when omitted.
This dataset's assets, as an iterator that fetches pages as you consume it.
The named graph with this IRI.
The graph's IRI, as a string or an RDF/JS named node.
Resolved by listing the dataset's graphs and comparing IRIs, so the cost grows with the number of graphs. Prefer Dataset.getGraphs when you are going to look at several of them.
This dataset's named graphs, as an iterator that fetches pages as you consume it.
This dataset's metadata: its name, description, access level, prefixes and statement counts.
true to refetch, or an object also accepting an AbortSignal.
Every prefix that applies to this dataset, including the instance-wide ones.
Fetch again rather than reusing the cached result.
Prefix labels mapped to the IRIs they stand for.
Cached after the first call, and refreshed by addPrefixes and removePrefixes.
The service with this name.
The service's name, as given when it was created.
Being able to get a service does not mean it can answer queries — check Service.isUpToDate or wait with Service.waitUntilRunning.
This dataset's services, as an iterator that fetches pages as you consume it.
Statements matching a pattern, as an iterator that fetches pages as you consume it.
The terms to match on, each an IRI or literal in its RDF form.
Writes this dataset's statements to a file.
Where to write, extension included.
Optionalopts: { compressed?: boolean; graph?: Graph }
graph narrows the export to a single graph; compressed gzips the output.
Loads this dataset's statements into an in-memory store.
Optionalgraph: Graph
Load only this graph instead of the whole dataset.
Everything is held in memory at once — use Dataset.graphsToStream for large data.
Streams this dataset's statements, for data too large to hold in memory.
"rdf-js" for parsed RDF/JS quads, "compressed" for the raw gzipped bytes.
Optionalopts: { extension?: string; graph?: Graph }
graph narrows to a single graph; extension picks the serialisation, .trig
by default.
Copies graphs from another dataset on the same instance into this one.
The dataset to take graphs from.
Optionalargs: ImportFromDatasetArgs
Which graphs to take, and what to name them here. All graphs are taken when omitted.
Loads RDF files from disk into this dataset.
Paths, or File objects. Each file's graph comes from the file itself, so use
a quad format such as TriG to control it.
OptionaldefaultsConfig: JobDefaultsConfig
Fallbacks for files that name no graph, and the base IRI to resolve relative IRIs against.
Runs as a job on the server and resolves once it has finished, so a large upload keeps the promise pending rather than returning early. Statements are added to what is already there.
Each file is parsed according to its extension rather than by sniffing its contents, and one
whose extension is not recognised is skipped: the import still succeeds, and the skip is not
reported back here. RDF serializations: .nt, .nq, .ttl, .trig, .n3, .jsonld,
.rdf, .rdfs, .owl, .owx. Other formats, mapped to RDF on the way in: .json, .jsonl,
.ndjson, .csv, .tsv, .xml, .gpx. Any of these may arrive compressed or archived as
.gz, .bz2, .xz, .zip, .tar or .tgz, including combinations such as .trig.gz.
Loads the contents of an in-memory store into this dataset.
Optionalopts: JobDefaultsConfigConvenient for data you have just built or transformed in process. The store is written to a temporary N-Quads file and handed to Dataset.importFromFiles, so it needs room on disk and behaves the same way from there — including refusing to run beside another import.
Loads RDF from URLs into this dataset.
OptionaldefaultConfig: JobDefaultsConfigRemoves IRI prefix declarations from this dataset.
The aliases to remove.
Changes one graph's IRI, keeping its statements.
The graph's current IRI.
Its new IRI.
Replaces this dataset's image.
Path to an image file, or its contents.
Runs a SPARQL query against this dataset.
The query to run.
Answered by TriplyDB's built-in engine, which reads the dataset's data directly and so needs no service. To query a service instead, use Service.sparqlQuery on it.
Nothing is sent until you pick a result form on what this returns — see SparqlResults. Every form is a single request that returns the whole result set.
This call itself never throws: an unusable query is reported by the result form you await, so
a single catch covers both that and the request.
SPARQL Update goes through Dataset.sparqlUpdate instead.
Applies a SPARQL Update to this dataset.
The update to apply.
The whole update is one transaction: either every operation in it takes effect, or none does. Queries go through Dataset.sparqlQuery instead.
Attaches a file to this dataset as an asset.
Path to the file, or a File object.
Optionalopts: { mode?: UploadAssetModes; name?: string }
name overrides the asset name, which otherwise is the file's own name without
its directories. mode decides what happens when that name is taken: refuse (the default),
replace it, or keep both by adding a version.
Attaches a file to this dataset as an asset, under this name.
Path to the file, or a File object.
Optionalname: string
Name for the asset; the file's own name, without its directories, is used when omitted.
A TriplyDB dataset: a collection of named graphs, together with its services and assets.
Remarks
Obtain one from an Account with
getDataset,addDatasetorensureDataset. Datasets are never constructed directly.Example: Get a dataset that already exists
Example: Create it on first run, then load a file into it