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.

etrieve()<br />

Example 2 (type = “list”): Retrieve a list of address lines for a specific customer<br />

mydata.retrieve(<br />

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

"list",<br />

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

);<br />

Result:<br />

Two lines in the address for customer number 1:<br />

[1, 2]<br />

Example 3 (type = “array”): Retrieve all data for a customer<br />

mydata.retrieve(<br />

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

"array",<br />

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

);<br />

Result:<br />

[<br />

]<br />

{ global: "Customer",<br />

subscripts: [1],<br />

data: "Chris Munt"<br />

}<br />

{ global: "Customer",<br />

subscripts: [1, "Address", 1],<br />

data: "London"<br />

}<br />

{ global: "Customer",<br />

subscripts: [1, "Address", 2],<br />

data: "UK"<br />

}<br />

{ global: "Customer",<br />

subscripts: [1, "DateOfRegistration],<br />

data: "1 May 2010"<br />

}<br />

Example 4 (type = “object”): Retrieve all data for a customer<br />

Consider the following structured <strong>Caché</strong> global:<br />

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

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

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

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

In <strong>Node</strong>.<strong>js</strong>:<br />

mydata.retrieve(<br />

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

"object",<br />

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

);<br />

Result:<br />

{<br />

}<br />

node: {<br />

global: "Customer",<br />

subscripts: [1]<br />

}<br />

object: {<br />

Name: "Chris Munt",<br />

Address: {"1": "London", "2": "UK"},<br />

DateOfRegistration: "1 May 2010"<br />

}<br />

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

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

Saved successfully!

Ooh no, something went wrong!