Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Overview

Performs an xquery on repository and returns the results as string array. Queries the domain database by default if not specified. See XML $Database page for further information about domain and process databases.

Array<string> $XmlRepository.Query(xquery: string)

Performs an xquery on repository and returns the results as string array. Queries the domain database by default if not specified. See XML $Database page for further information about domain and process databases.

Array<string> $XmlRepository.Query(xquery: string, parameters: object)

Arguments

string xquery
Specifies the query to perform on the database. The syntax of the query is quite detailed. More information can be found on xquery standard page.
string xquery
Specifies the query to perform on the database. The syntax of the query is quite detailed. More information can be found on xquery standard page. ,
object parameters
Specifies the binding parameters on xquery string.

Remarks

If query does not return any result than return value is empty array.

The examples below shows how to query the domain database. To see how to query a process database check the latterexamples.

Example

Find all customers

var results = $XmlRepository.Query('//Customer');
$Xml.InnerXml( 'Customer', results.join() );

Example

Find customer by id

var results = $XmlRepository.Query('//Customer[Id=$id]', {
id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results.join() );

Example

Query Update

$XmlRepository.Query('for $customer in //Customer[Id=$id] return replace value of node $customer/Name with "Lady Gaga"', {
   id : $Xml.Evaluate('CustomerId')
});

Example

Query Insert

$XmlRepository.Query('insert node (<Kaynak><Id>{$newId}</Id><Ad>{$newName}</Ad></Kaynak>) as last into /KVKEnvanter/Tanimlar/Kaynaklar', {
    newId: newId,
    newName: name.trim()
});

Example

Query Delete

$XmlRepository.Query('let $nodeValue := fn:parse-xml-fragment($nodeValue)' +
                     'for $record in Relation[Id=$id]/RepHistory/RepHistoryRecord[InstanceId=$instanceId] return ' +
                     '(delete node $record)', {
   id : relationId,
   instanceId : $Xml.Evaluate('SelectedHistory/Id'),
   nodeValue : $Xml.SelectSingle('.').InnerXml()
});

Example

Querying process database

var results = $XmlRepository.Query('collection("49551ed3-6229-408a-aaaa-eb510463acad")//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );

Remarks

If query does not return any result than return value is empty array.

The examples below shows how to query the domain database. To see how to query a process database check the latter examples.

Example

Find all customers

var results = $XmlRepository.Query('//Customer');
$Xml.InnerXml( 'Customer', results.join() );

Example

Find customer by id

var results = $XmlRepository.Query('//Customer[Id=$id]', {
id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results.join() );

Example

Query Update

$XmlRepository.Query('for $customer in //Customer[Id=$id] return replace value of node $customer/Name with "Lady Gaga"', {
   id : $Xml.Evaluate('CustomerId')
});

Example

Query Insert

$XmlRepository.Query('insert node (<Kaynak><Id>{$newId}</Id><Ad>{$newName}</Ad></Kaynak>) as last into /KVKEnvanter/Tanimlar/Kaynaklar', {
    newId: newId,
    newName: name.trim()
});

Example

Query Delete

$XmlRepository.Query('let $nodeValue := fn:parse-xml-fragment($nodeValue)' +
                     'for $record in Relation[Id=$id]/RepHistory/RepHistoryRecord[InstanceId=$instanceId] return ' +
                     '(delete node $record)', {
   id : relationId,
   instanceId : $Xml.Evaluate('SelectedHistory/Id'),
   nodeValue : $Xml.SelectSingle('.').InnerXml()
});

Example

Querying process database
var results = $XmlRepository.Query('collection("49551ed3-6229-408a-aaaa-eb510463acad")//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );

Examples

Find all customers
var results = $XmlRepository.Query('//Customer');
$Xml.InnerXml( 'Customer', results.join() );
Find customer by id
var results = $XmlRepository.Query('//Customer[Id=$id]', {
id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results.join() );
Query Update
$XmlRepository.Query('for $customer in //Customer[Id=$id] return replace value of node $customer/Name with "Lady Gaga"', {
   id : $Xml.Evaluate('CustomerId')
});
Query Insert
$XmlRepository.Query('insert node (<Kaynak><Id>{$newId}</Id><Ad>{$newName}</Ad></Kaynak>) as last into /KVKEnvanter/Tanimlar/Kaynaklar', {
    newId: newId,
    newName: name.trim()
});
Query Delete
$XmlRepository.Query('let $nodeValue := fn:parse-xml-fragment($nodeValue)' +
                     'for $record in Relation[Id=$id]/RepHistory/RepHistoryRecord[InstanceId=$instanceId] return ' +
                     '(delete node $record)', {
   id : relationId,
   instanceId : $Xml.Evaluate('SelectedHistory/Id'),
   nodeValue : $Xml.SelectSingle('.').InnerXml()
});
Querying process database
var results = $XmlRepository.Query('collection("49551ed3-6229-408a-aaaa-eb510463acad")//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );
Querying process database
var results = $XmlRepository.Query('collection("49551ed3-6229-408a-aaaa-eb510463acad")//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );
  • No labels