Skip to content

GetDatabase

Returns a Database instance that runs queries against the specified data store.

1
$Database.GetDatabase(storeName: string):$Database

Parameters

string storeName
    The ID of the data store. The name of a shared data store, prefixed with PS_, is also accepted.

Returns

A Database instance bound to the data store.

Remarks

The returned instance has the same members as $Database. Use it when several operations target the same non-default data store, instead of repeating TargetDataStore in every query.

Examples

Query a non-default data store

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// ID of the archive data store
var archive = $Database.GetDatabase('3f2b8c1e-7a4d-4e9b-9c0a-5d6e7f8a9b10');

var orders = archive.Get({
    TargetSchema : 'Sales',
    TargetTable : 'Orders',
    Where : {
        Criteria : [
            { Expression : 'Customer', Value : $Xml.Evaluate('Customer/Id') }
        ]
    }
});

See Also