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.

3<br />

Accessing <strong>Caché</strong> from <strong>Node</strong>.<strong>js</strong><br />

The cache.node module provides the basic NoSQL-style methods, and also has more advanced methods that can be used<br />

to implement a higher-level view of the <strong>Caché</strong> database which can, in turn, form the basis of an object oriented approach<br />

to development. This chapter provides an overview of the available methods and the concepts behind them.<br />

The following topics are discussed:<br />

• JSON Objects and <strong>Caché</strong> Globals — describes the basic relationship between the globals in the <strong>Caché</strong> database and<br />

JSON objects in the <strong>Node</strong>.<strong>js</strong> environment.<br />

• Synchronous vs. Asynchronous cache.node Methods — describes how to use cache.node calls both synchronously<br />

and asynchronously.<br />

• Overview of cache.node Methods — provides a quick overview of the basic NoSQL-style cache.node database methods.<br />

• Opening and Closing the <strong>Caché</strong> Database — describes how to load the cache.node module, create an instance of the<br />

cache.node object, and open or close the target <strong>Caché</strong> database.<br />

• Advanced Data Access <strong>with</strong> retrieve() and update() — describes advanced cache.node methods that perform certain<br />

operations more efficiently than the basic NoSQL-style methods.<br />

• Towards an Object Oriented Development Methodology — illustrates how the cache.node methods and JSON notation<br />

can be used for object orientated development.<br />

3.1 JSON Objects and <strong>Caché</strong> Globals<br />

In this section we will look at the basic relationship between JSON objects in the <strong>Node</strong>.<strong>js</strong> environment and globals in the<br />

<strong>Caché</strong> database.<br />

Consider the following global node:<br />

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

Note:<br />

By convention, global names are prefixed <strong>with</strong> the ‘^’ character in <strong>Caché</strong>. However, this convention should not<br />

be followed in the corresponding JSON representation.<br />

The equivalent JSON construct will be:<br />

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

Adding further nodes to this data construct:<br />

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

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

Saved successfully!

Ooh no, something went wrong!