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.

Advanced Data Access <strong>with</strong> retrieve() and update()<br />

mydata.close([function(error, result){}]);<br />

3.5 Advanced Data Access <strong>with</strong> retrieve() and update()<br />

This section describes advanced methods that perform operations that could otherwise be achieved by combining several<br />

of the basic NoSQL-style methods.<br />

The following topics are discussed:<br />

• <strong>Using</strong> retrieve() — describes retrieving groups of global nodes as a single JSON object<br />

• <strong>Using</strong> update() — describes writing a single JSON object to update groups of global nodes.<br />

The following <strong>Caché</strong> data will be used to illustrate the higher level methods.<br />

^Customer(1)="Chris Munt"<br />

^Customer(1, "Address", 1)="London"<br />

^Customer(1, "Address", 2)="UK"<br />

^Customer(1, "DateOfRegistration")="1 May 2010"<br />

^Customer(2)="Rob Tweed"<br />

^Customer(2, "Address", 1)="Reigate"<br />

^Customer(2, "Address", 2)="UK"<br />

^Customer(2, "DateOfRegistration")="7 May 2010"<br />

^Customer(3)="Jane Smith"<br />

^Customer(3, "Address", 1)="Oxford"<br />

^Customer(3, "Address", 2)="UK"<br />

^Customer(3, "DateOfRegistration")="9 June 2010"<br />

3.5.1 <strong>Using</strong> retrieve()<br />

The following topics are discussed:<br />

• Retrieve a list of global nodes (retrieve("list"))<br />

• Retrieve a list of global nodes recursively (retrieve("array"))<br />

• Retrieve a structured data object (retrieve("object"))<br />

• Controlling the amount of data returned by retrieve operations<br />

3.5.1.1 Retrieve a list of global nodes (retrieve("list"))<br />

This method will return a list of subscript values that are defined directly beneath a given level in the global.<br />

Example 1: Retrieve a list of customer numbers<br />

mydata.retrieve(<br />

{global: "Customer"},<br />

"list",<br />

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

);<br />

Result:<br />

Three Customer records:<br />

[1, 2, 3]<br />

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

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

Saved successfully!

Ooh no, something went wrong!