Using Node.js with Caché - InterSystems Documentation
Using Node.js with Caché - InterSystems Documentation
Using Node.js with Caché - InterSystems Documentation
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 />
3.5.2 <strong>Using</strong> update()<br />
The update() method allows an application to save a group of global nodes by passing information saved in a single JSON<br />
object. The nodes can represent either an array or an object:<br />
• Save a list of global nodes (update("array"))<br />
• Save a structured data object (update("object"))<br />
3.5.2.1 Save a list of global nodes (update("array"))<br />
This method performs the opposite task to that performed by the retrieve method. In other words the update method takes<br />
an array of global nodes, each expressed as a single JSON object and writes them back to the <strong>Caché</strong> database.<br />
Example 1: Create or update a record for a customer<br />
mydata.update(<br />
[<br />
{<br />
global: "Customer",<br />
subscripts: [1],<br />
data: "Chris Munt"<br />
}<br />
{<br />
global: "Customer",<br />
subscripts: [1, "Address", 1],<br />
data: "London"<br />
}<br />
{<br />
global: "Customer",<br />
subscripts: [1, "Address", 2],<br />
data: "UK"<br />
}<br />
{<br />
global: "Customer",<br />
subscripts: [1, "DateOfRegistration"],<br />
data: "1 May 2010"<br />
}<br />
],<br />
"array",<br />
function(error, result) { // callback code }<br />
);<br />
Result:<br />
Operation successful if no error reported.<br />
3.5.2.2 Save a structured data object (update("object"))<br />
This method performs the opposite task to that performed by the retrieve method. In other words it writes the contents of<br />
a structured JSON object back to the <strong>Caché</strong> database.<br />
Example 1: Create or update a record for a customer<br />
mydata.update(<br />
node: {<br />
global: "Customer",<br />
subscripts: [1]<br />
},<br />
Object: {<br />
Name: "Chris Munt",<br />
DateOfRegistration: "1 May 2010",<br />
Address: {"1": "London", "2": "UK"}<br />
},<br />
"object",<br />
function(error, result) { // callback code }<br />
);<br />
Result:<br />
<strong>Using</strong> <strong>Node</strong>.<strong>js</strong> <strong>with</strong> <strong>Caché</strong> 15