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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

previous_node()<br />

Asynchronous<br />

Parameters<br />

mydata.previous(node, callback_function);<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 = mydata.previous_node({global: "Customer", subscripts: ["z"]},<br />

Result:<br />

{global: "Customer", subscripts: [3], data: "Jane Smith", defined: 1}}<br />

Example 2 (Synchronous)<br />

result = mydata.next_node({global: "Customer", subscripts: [2]},<br />

Result:<br />

{<br />

}<br />

global: "Customer",<br />

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

data: "Banstead",<br />

defined: 1<br />

Example 3 (Asynchronous)<br />

mydata.previous_node(<br />

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

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

);<br />

Result:<br />

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

Example 4 (Parse Global)<br />

key = {global: "Customer", subscripts: ["z"]};<br />

while ((key = user.previous_node(key)).defined) {<br />

console.log(JSON.stringify(key, null, '\t'));<br />

}<br />

Result:<br />

{<br />

}<br />

{<br />

}<br />

{<br />

}<br />

{<br />

global: "Customer",<br />

subscripts: [3],<br />

data: "Jane Smith",<br />

defined: 1<br />

global: "Customer",<br />

subscripts: [2],<br />

data: "Rob Tweed",<br />

defined: 1<br />

global: "Customer",<br />

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

data: "Banstead",<br />

defined: 1<br />

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

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

Saved successfully!

Ooh no, something went wrong!