25.01.2015 Views

Using Node.js with Caché - InterSystems Documentation

Using Node.js with Caché - InterSystems Documentation

Using Node.js with Caché - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

global_directory()<br />

Parameters<br />

• node — the global node to be accessed.<br />

• callback_function — a function of the form function(error, result){} used to return results<br />

asynchronously (see “Synchronous vs. Asynchronous cache.node Methods”).<br />

Example 1 (Synchronous)<br />

Result:<br />

result = mydata.get({global: "Customer", subscripts: [9]});<br />

{global: "Customer", subscripts: [9], data: "", defined: 0}<br />

Example 2 (Asynchronous)<br />

mydata.get(<br />

{global: "Customer", subscripts: [1]},<br />

function(error, result) { // callback code }<br />

);<br />

Result:<br />

{global: "Customer", subscripts: [1], data: "Chris Munt", defined: 1}<br />

Note that the ‘defined’ property is set to 1 if the global node is actually defined and set to 0 if it is not.<br />

4.6 global_directory()<br />

The global_directory() method returns a list of globals held in the directory. The number of names returned can be controlled<br />

using the range limiting properties ‘lo’, ‘hi’ and ‘max’ (see “Controlling the amount of data returned by retrieve operations”).<br />

Synchronous<br />

Asynchronous<br />

Parameters<br />

var result = mydata.global_directory(range);<br />

mydata.global_directory (range, callback_function);<br />

• range<br />

• callback_function — a function of the form function(error, result){} used to return results<br />

asynchronously (see “Synchronous vs. Asynchronous cache.node Methods”).<br />

Example 1: Obtain a list of all globals in the directory<br />

mydata.global_directory(<br />

{},<br />

function(error, result) { // callback code }<br />

);<br />

Result:<br />

If successful, an array containing all global names found will be returned.<br />

<strong>Using</strong> <strong>Node</strong>.<strong>js</strong> <strong>with</strong> <strong>Caché</strong> 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!