Skip to content

Commit

Permalink
Merge pull request #121 from TriplyDB/query-addVersion-duplicate-func…
Browse files Browse the repository at this point in the history
…tions

Query add version , duplicate functions update
  • Loading branch information
charitha93 authored Apr 8, 2024
2 parents a55a6fd + fd23cd1 commit f80eaef
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion docs/triplydb-js/query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ At least one of the following arguments is required to create a new version. Any
<dd>the SPARQL compliant query as a string value</dd>

<dt><code>output: string</code></dt>
<dd>The visualization plugin that is used to display the result set. If none is set it defaults to <code>'table'</code>. Other options may include: <code>'response'</code>, <code>'geo'</code>, <code>'gallery'</code>, <code>'markup'</code>, etc</dd>
<dd>The visualization plugin that is used to display the result set. If none is set it defaults to <code>'table'</code>. Other options may include: <code>'response'</code>, <code>'geo'</code>, <code>'gallery'</code>, <code>'markup'</code>, etc. Output will take priority over ldFrame</dd>

<dt><code> ldFrame: object</code></dt>
<dd>JSON LD frame object used to transform plain JSON LD into a framed JSON. Will be used only if an output is not provided.</dd>

<dt><code>variables: Variable[]</code></dt>
<dd>
Expand Down Expand Up @@ -212,3 +215,72 @@ const user = await triply.getAccount('my-account')
const query = await user.getQuery('my-query')
const query_1 = await query.useVersion(1)
```

## Query.duplicate(name: string, metadataToReplace?: object)

Creates a duplicate of the saved query under a new <code>name</code>. The duplicated query will retain all the metadata from the original query unless <code>metadataToReplace</code> has been provided.

### Arguments

<dl>
<dt><code>name</code></dt>
<dd>
<p>The new URL-friendly name given to the duplicated query that is used in URL paths. This name can only include ASCII letters and hyphens.</p>
</dd>

<dt><code>metadataToReplace</code><dt>
<dd>
<p>An optional metadata object with optionl properties that can be provided to override any of the existing metadata of the duplicated query if required</p>
<dl>
<dt><code>accessLevel</code></dt>
<dd>
<p>The access level of the query. The following values are possible:</p>
<dl>
<dt><code>'private'</code> (default)</dt>
<dd>The dataset can only be accessed by organization members.</dd>
<dt><code>'internal'</code></dt>
<dd>The dataset can only be accessed by users that are logged into the TriplyDB server.
<dt><code>'public'</code></dt>
<dd>The dataset can be accessed by everybody.</dd>
</dl>
</dd>
<dt><code>queryString: string</code></dt>
<dd>the SPARQL compliant query as a string value</dd>
<dt><code>output: string</code></dt>
<dd>The visualization plugin that is used to display the result set. If none is set it defaults to <code>'table'</code>. Other options may include: <code>'response'</code>, <code>'geo'</code>, <code>'gallery'</code>, <code>'markup'</code>, etc</dd>
<dt><code>dataset: object</code></dt>
<dd>A dictionary object representing the dataset against which the query is evaluated.</dd>
<dt><code>description: string</code></dt>
<dd>The human-readable description of the query. This typically explains what the query does in natural language.</dd>
<dt><code>displayName: string</code></dt>
<dd>The human-readable name of the query. This name may include spaces and other characters that are not allowed in the URL-friendly name.</dd>
<dt><code>variables: Variable[]</code></dt>
<dd>
<p>A list of objects with the following keys:</p>
<dl>
<dt>IRI variable</dt>
<dd>An object of the form `Variable`
(see <a href="../account/index.md#accountaddqueryname-string-metadata-object">Account.addQuery()</a>)
</dd>
</dd>
<dt><code>serviceType: string</code>("speedy" | "virtuoso" | "jena" | "blazegraph" | "prolog")</dt>
<dd>The SPARQL service type the duplicated query needs to be configured to</dd>
</dl>
</dd>
</dl>

### Example

```ts
const user = await triply.getAccount('my-account')
const query = await user.getQuery('my-query')
const query_1 = await query.useVersion(1)

// Without overwriting any metadata
const duplicatedQuery_1 = await query.duplicate('newDuplicateQuery')
// With overwitting metadata
const duplicatedQuery_1 = await query.duplicate('newDuplicateQuery', {
description: 'newDescription',
displayName: 'newDisplayName'
})
```

0 comments on commit f80eaef

Please sign in to comment.