SlideShare a Scribd company logo
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 20
JavaScript Abstraction of Global Storage:
(a) The DocumentNode Object
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
Underlying Concept
Copyright © 2016 M/Gateway Developments Ltd
myGlobal("a")=123
myGlobal("b","c1")="foo"
myGlobal("b","c2")="foo2"
myGlobal("d","e1","f1")="bar1"
myGlobal("d","e1","f2")="bar2"
myGlobal("d","e2","f1")="bar1"
myGlobal("d","e2","f2")="bar2"
myGlobal("d","e2","f3")="bar3"
myGlobal
"a" 123
"b"
"c2" "foo2"
"d"
"c1" "foo"
"e2"
"e1"
"f2" "bar2"
"f1" "bar1"
"f2" "bar2"
"f1" "bar1"
"f3" "bar3"
Hierarchical diagram representing a Global
Copyright © 2016 M/Gateway Developments Ltd
myGlobal = {
a: 123,
b: {
c1: 'foo',
c2: 'foo2'
}
d: {
e1: {
f1: 'bar1',
f2: 'bar2'
},
e2: {
f1: 'bar1',
f2: 'bar2',
f3: 'bar3'
}
}
}
myGlobal("a")=123
myGlobal("b","c1")="foo"
myGlobal("b","c2")="foo2"
myGlobal("d","e1","f1")="bar1"
myGlobal("d","e1","f2")="bar2"
myGlobal("d","e2","f1")="bar1"
myGlobal("d","e2","f2")="bar2"
myGlobal("d","e2","f3")="bar3"
One to one correspondence between any tree of Global nodes
and a Javascript object
Copyright © 2016 M/Gateway Developments Ltd
myGlobal = {
a: 123,
b: {
c1: 'foo',
c2: 'foo2'
}
d: {
e1: {
f1: 'bar1',
f2: 'bar2'
},
e2: {
f1: 'bar1',
f2: 'bar2',
f3: 'bar3'
}
}
}
myGlobal("a")=123
myGlobal("b","c1")="foo"
myGlobal("b","c2")="foo2"
myGlobal("d","e1","f1")="bar1"
myGlobal("d","e1","f2")="bar2"
myGlobal("d","e2","f1")="bar1"
myGlobal("d","e2","f2")="bar2"
myGlobal("d","e2","f3")="bar3"
Subscript <=> Property
Copyright © 2016 M/Gateway Developments Ltd
myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3
Global Node JavaScript Object
Copyright © 2016 M/Gateway Developments Ltd
myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3
Global Node JavaScript Object
But…
JavaScript Objects are in memory
Global Nodes are persistent, on disk
Copyright © 2016 M/Gateway Developments Ltd
myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3
Global Node JavaScript Object
Could we abstract Global Nodes as
Persistent JavaScript Objects?
Copyright © 2016 M/Gateway Developments Ltd
ewd-document-store
- JavaScript Abstraction of Global Storage
https://github.com/robtweed/ewd-document-store
Layered on top of the basic cache.node APIs
Copyright © 2016 M/Gateway Developments Ltd
ewd-document-store
- JavaScript Abstraction of Global Storage
https://github.com/robtweed/ewd-document-store
Layered on top of the basic cache.node APIs
Loaded automatically into QEWD workers
Copyright © 2016 M/Gateway Developments Ltd
ewd-document-store
- JavaScript Abstraction of Global Storage
https://github.com/robtweed/ewd-document-store
Layered on top of the basic cache.node APIs
Loaded automatically into QEWD workers
Made accessible in QEWD by this.documentStore
Copyright © 2016 M/Gateway Developments Ltd
ewd-document-store
- JavaScript Abstraction of Global Storage
https://github.com/robtweed/ewd-document-store
Layered on top of the basic cache.node APIs
Loaded automatically into QEWD workers
Made accessible in QEWD by this.documentStore
Can also be used standalone for testing and debugging
Copyright © 2016 M/Gateway Developments Ltd
ewd-document-store
- JavaScript Abstraction of Global Storage
Use in a test harness:
See example in:
https://github.com/robtweed/ewd-document-store/blob/master/lib/tests/CacheStandalone.js
Copyright © 2016 M/Gateway Developments Ltd
Edit CacheStandalone.js
var DocumentStore = require('ewd-document-store');
var interface = require('cache');
var db = new interface.Cache();
console.log('db: ' + JSON.stringify(db));
// Change these parameters to match your GlobalsDB or Cache system:
var ok = db.open({
path: '/opt/cache/mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
console.log('ok: ' + JSON.stringify(ok));
var documentStore = new DocumentStore(db);
console.log(db.version());
var rob = new documentStore.DocumentNode('rob');
Copyright © 2016 M/Gateway Developments Ltd
Edit CacheStandalone.js
var DocumentStore = require('ewd-document-store');
var interface = require('cache');
var db = new interface.Cache();
console.log('db: ' + JSON.stringify(db));
// Change these parameters to match your GlobalsDB or Cache system:
var ok = db.open({
path: 'C:InterSystemsCache2015-2mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
console.log('ok: ' + JSON.stringify(ok));
var documentStore = new DocumentStore(db);
console.log(db.version());
var rob = new documentStore.DocumentNode('rob');
Copyright © 2016 M/Gateway Developments Ltd
Save as
C:qewddocStoreTest.js
var DocumentStore = require('ewd-document-store');
var interface = require('cache');
var db = new interface.Cache();
console.log('db: ' + JSON.stringify(db));
// Change these parameters to match your GlobalsDB or Cache system:
var ok = db.open({
path: 'C:InterSystemsCache2015-2mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
console.log('ok: ' + JSON.stringify(ok));
var documentStore = new DocumentStore(db);
console.log(db.version());
var rob = new documentStore.DocumentNode('rob');
Copyright © 2016 M/Gateway Developments Ltd
Version for use with GT.M
var DocumentStore = require('ewd-document-store');
var interface = require('nodem');
var db = new interface.Gtm();
console.log('db: ' + JSON.stringify(db));
var ok = db.open();
console.log('ok: ' + JSON.stringify(ok));
var documentStore = new DocumentStore(db);
console.log(db.version());
var rob = new documentStore.DocumentNode('rob');
Copyright © 2016 M/Gateway Developments Ltd
Version for use with ewd-redis-globals
var DocumentStore = require('ewd-document-store');
var interface = require('ewd-redis-globals');
var db = new interface();
console.log('db: ' + JSON.stringify(db));
var ok = db.open();
console.log('ok: ' + JSON.stringify(ok));
var documentStore = new DocumentStore(db);
console.log(db.version());
var rob = new documentStore.DocumentNode('rob');
Copyright © 2016 M/Gateway Developments Ltd
Run it
cd qewd (or cd /qewd )
node docStoreTest
Copyright © 2016 M/Gateway Developments Ltd
Run it
cd ewd3
node docStoreTest
It runs a set of examples using DocumentNode objects
You can use it as the basis of your own test harness
Copyright © 2016 M/Gateway Developments Ltd
Adapting your own test harness
var DocumentStore = require('ewd-document-store');
var interface = require('cache');
var db = new interface.Cache();
var ok = db.open({
path: 'C:InterSystemsCache2015-2mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
var documentStore = new DocumentStore(db);
// delete and replace everything from this point onwards
// documentStore provides you with the abstracted interface to your database
// use this to try out the following examples for yourself
// simply replace this.documentStore with documentStore
Copyright © 2016 M/Gateway Developments Ltd
The DocumentNode Object
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new documentStore.DocumentNode(name, subscripts);
when using standalone test harness
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode(name, subscripts);
when using QEWD
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode(name, subscripts);
Represents a node within a document store hierarchy
May or may not physically exist at this point
ie this does NOT create a node
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode(name, subscripts);
Represents a node within a document's hierarchy
May or may not physically exist at this point
ie this does NOT create a node
Creates an instance of an object that represents that node, with
a set of methods and properties to manipulate and access that node
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
get: var x = dnode.value;
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
get: var x = dnode.value;
value is a read/write property
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
get: var x = dnode.value;
delete: dnode.delete();
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
get: var x = dnode.value;
delete: dnode.delete();
Note: delete will also delete any lower-level DocumentNodes
in the underlying Global Storage tree
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
represents myDoc("d","e2")
create: dnode.value = 'foo2';
get: var x = dnode.value;
delete: dnode.delete();
exists?: var exists = dnode.exists; // true | false
Copyright © 2016 M/Gateway Developments Ltd
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
var dnode = new this.documentStore.DocumentNode('myDoc', ['d']);
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d']);
dnode.hasChildren // true
dnode.hasValue // false
dnode.exists // true
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
dnode.hasChildren // true
dnode.hasValue // false
dnode.exists // true
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f3']);
dnode.hasChildren // false
dnode.hasValue // true
dnode.exists // true
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f4']);
dnode.hasChildren // false
dnode.hasValue // false
dnode.exists // false
Even though the node doesn’t physically exist, you can define a
DocumentNode Object for it
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f3']);
dnode.name // f3 Node Name === last global subscript
dnode.parent // myDoc("d","e2")
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
Returns a DocumentNode Object
Copyright © 2016 M/Gateway Developments Ltd
var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']);
dnode.firstChild // myDoc("d","e2","f1")
dnode.lastChild // myDoc("d","e2","f3")
dnode.previousSibling // myDoc("d","e1")
dnode.nextSibling // undefined
myDoc("a")=123
myDoc("b","c1")="foo"
myDoc("b","c2")="foo2"
myDoc("d","e1","f1")="bar1"
myDoc("d","e1","f2")="bar2"
myDoc("d","e2","f1")="bar1"
myDoc("d","e2","f2")="bar2"
myDoc("d","e2","f3")="bar3"
DocumentNode
Objects
Copyright © 2016 M/Gateway Developments Ltd
DocumentNode Object
• We’ll further explore it in subsequent parts
of this course
• For more / additional information:
– http://gradvs1.mgateway.com/download/ewd-document-store.pdf

More Related Content

PDF
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
PDF
EWD 3 Training Course Part 11: Handling Errors in QEWD
PDF
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
PPT
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
PPT
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js

What's hot (20)

PDF
EWD 3 Training Course Part 2: EWD 3 Overview
PDF
Overview of The Scala Based Lift Web Framework
PDF
Overview Of Lift Framework
PDF
Design & Performance - Steve Souders at Fastly Altitude 2015
PDF
Web Development with NodeJS
PDF
Aligning Ember.js with Web Standards
PPTX
Head first asp.net mvc 2.0 rtt
PDF
Rapid Application Development with WSO2 Platform
PDF
Rails Caching Secrets from the Edge
PDF
Grails Launchpad - From Ground Zero to Orbit
PDF
Micronaut For Single Page Apps
PDF
Managing user's data with Spring Session
PDF
Resource registries plone conf 2014
PDF
EWD 3 Training Course Part 21: Persistent JavaScript Objects
KEY
Couchdb: No SQL? No driver? No problem
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
PDF
Choosing a Javascript Framework
PDF
Spring Boot Revisited with KoFu and JaFu
KEY
Html5 For Jjugccc2009fall
PDF
Web前端性能优化 2014
EWD 3 Training Course Part 2: EWD 3 Overview
Overview of The Scala Based Lift Web Framework
Overview Of Lift Framework
Design & Performance - Steve Souders at Fastly Altitude 2015
Web Development with NodeJS
Aligning Ember.js with Web Standards
Head first asp.net mvc 2.0 rtt
Rapid Application Development with WSO2 Platform
Rails Caching Secrets from the Edge
Grails Launchpad - From Ground Zero to Orbit
Micronaut For Single Page Apps
Managing user's data with Spring Session
Resource registries plone conf 2014
EWD 3 Training Course Part 21: Persistent JavaScript Objects
Couchdb: No SQL? No driver? No problem
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Choosing a Javascript Framework
Spring Boot Revisited with KoFu and JaFu
Html5 For Jjugccc2009fall
Web前端性能优化 2014
Ad

Viewers also liked (20)

PDF
EWD 3 Training Course Part 19: The cache.node APIs
PDF
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
PDF
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
PDF
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
PDF
EWD 3 Training Course Part 25: Document Database Capabilities
PDF
EWD 3 Training Course Part 26: Event-driven Indexing
PDF
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
PDF
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
PDF
EWD 3 Training Course Part 9: Complex QEWD Messages and Responses
PDF
EWD 3 Training Course Part 16: QEWD Services
PDF
EWD 3 Training Course Part 4: Installing & Configuring QEWD
PDF
EWD 3 Training Course Part 30: Modularising QEWD Applications
PDF
EWD 3 Training Course Part 27: The QEWD Session
PPT
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
PDF
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
PDF
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
PDF
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
PDF
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
PDF
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 9: Complex QEWD Messages and Responses
EWD 3 Training Course Part 16: QEWD Services
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
Ad

Similar to EWD 3 Training Course Part 20: The DocumentNode Object (20)

PDF
Avro, la puissance du binaire, la souplesse du JSON
PDF
Sparkling Water
PDF
Android and the Seven Dwarfs from Devox'15
PDF
Infrastructure-as-code: bridging the gap between Devs and Ops
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
KEY
[Coscup 2012] JavascriptMVC
PDF
Артем Маркушев - JavaScript
PDF
2014 09 30_sparkling_water_hands_on
PDF
Into The Box 2018 Going live with commandbox and docker
PDF
Going live with BommandBox and docker Into The Box 2018
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PPTX
Practical AngularJS
PPT
Mongo-Drupal
PDF
Book
PPT
Gradle: The Build system you have been waiting for
PDF
Web applications with Catalyst
PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
PDF
HTML5 for the Silverlight Guy
PDF
Middy.js - A powerful Node.js middleware framework for your lambdas​
PPTX
hacking with node.JS
Avro, la puissance du binaire, la souplesse du JSON
Sparkling Water
Android and the Seven Dwarfs from Devox'15
Infrastructure-as-code: bridging the gap between Devs and Ops
Burn down the silos! Helping dev and ops gel on high availability websites
[Coscup 2012] JavascriptMVC
Артем Маркушев - JavaScript
2014 09 30_sparkling_water_hands_on
Into The Box 2018 Going live with commandbox and docker
Going live with BommandBox and docker Into The Box 2018
Event-driven IO server-side JavaScript environment based on V8 Engine
Practical AngularJS
Mongo-Drupal
Book
Gradle: The Build system you have been waiting for
Web applications with Catalyst
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
HTML5 for the Silverlight Guy
Middy.js - A powerful Node.js middleware framework for your lambdas​
hacking with node.JS

More from Rob Tweed (16)

PDF
QEWD Update
PPT
Data Persistence as a Language Feature
PPT
LNUG: Having Your Node.js Cake and Eating It Too
PPT
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
PPT
QEWD.js, JSON Web Tokens & MicroServices
PPT
QEWD.js: Have your Node.js Cake and Eat It Too
PPT
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
PDF
qewd-ripple: The Ripple OSI Middle Tier
PPT
EWD 3 Training Course Part 42: The QEWD Docker Appliance
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
PDF
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
PDF
EWD 3 Training Course Part 35: QEWD Session Locking
PDF
EWD 3 Training Course Part 34: QEWD Resilient Mode
PDF
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
PDF
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
PDF
EWD 3 Training Course Part 29: Running QEWD as a Service
QEWD Update
Data Persistence as a Language Feature
LNUG: Having Your Node.js Cake and Eating It Too
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js: Have your Node.js Cake and Eat It Too
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
qewd-ripple: The Ripple OSI Middle Tier
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 29: Running QEWD as a Service

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
AI in Product Development-omnex systems
PDF
top salesforce developer skills in 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Introduction to Artificial Intelligence
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Strategies for Manufacturing Companies
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
L1 - Introduction to python Backend.pptx
Understanding Forklifts - TECH EHS Solution
2025 Textile ERP Trends: SAP, Odoo & Oracle
How Creative Agencies Leverage Project Management Software.pdf
history of c programming in notes for students .pptx
Softaken Excel to vCard Converter Software.pdf
AI in Product Development-omnex systems
top salesforce developer skills in 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Introduction to Artificial Intelligence
CHAPTER 2 - PM Management and IT Context
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
ISO 45001 Occupational Health and Safety Management System
Transform Your Business with a Software ERP System
Digital Strategies for Manufacturing Companies
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

EWD 3 Training Course Part 20: The DocumentNode Object

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 20 JavaScript Abstraction of Global Storage: (a) The DocumentNode Object Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd Underlying Concept
  • 3. Copyright © 2016 M/Gateway Developments Ltd myGlobal("a")=123 myGlobal("b","c1")="foo" myGlobal("b","c2")="foo2" myGlobal("d","e1","f1")="bar1" myGlobal("d","e1","f2")="bar2" myGlobal("d","e2","f1")="bar1" myGlobal("d","e2","f2")="bar2" myGlobal("d","e2","f3")="bar3" myGlobal "a" 123 "b" "c2" "foo2" "d" "c1" "foo" "e2" "e1" "f2" "bar2" "f1" "bar1" "f2" "bar2" "f1" "bar1" "f3" "bar3" Hierarchical diagram representing a Global
  • 4. Copyright © 2016 M/Gateway Developments Ltd myGlobal = { a: 123, b: { c1: 'foo', c2: 'foo2' } d: { e1: { f1: 'bar1', f2: 'bar2' }, e2: { f1: 'bar1', f2: 'bar2', f3: 'bar3' } } } myGlobal("a")=123 myGlobal("b","c1")="foo" myGlobal("b","c2")="foo2" myGlobal("d","e1","f1")="bar1" myGlobal("d","e1","f2")="bar2" myGlobal("d","e2","f1")="bar1" myGlobal("d","e2","f2")="bar2" myGlobal("d","e2","f3")="bar3" One to one correspondence between any tree of Global nodes and a Javascript object
  • 5. Copyright © 2016 M/Gateway Developments Ltd myGlobal = { a: 123, b: { c1: 'foo', c2: 'foo2' } d: { e1: { f1: 'bar1', f2: 'bar2' }, e2: { f1: 'bar1', f2: 'bar2', f3: 'bar3' } } } myGlobal("a")=123 myGlobal("b","c1")="foo" myGlobal("b","c2")="foo2" myGlobal("d","e1","f1")="bar1" myGlobal("d","e1","f2")="bar2" myGlobal("d","e2","f1")="bar1" myGlobal("d","e2","f2")="bar2" myGlobal("d","e2","f3")="bar3" Subscript <=> Property
  • 6. Copyright © 2016 M/Gateway Developments Ltd myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3 Global Node JavaScript Object
  • 7. Copyright © 2016 M/Gateway Developments Ltd myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3 Global Node JavaScript Object But… JavaScript Objects are in memory Global Nodes are persistent, on disk
  • 8. Copyright © 2016 M/Gateway Developments Ltd myGlobal("d","e2","f3") <=> myGlobal.d.e2.f3 Global Node JavaScript Object Could we abstract Global Nodes as Persistent JavaScript Objects?
  • 9. Copyright © 2016 M/Gateway Developments Ltd ewd-document-store - JavaScript Abstraction of Global Storage https://github.com/robtweed/ewd-document-store Layered on top of the basic cache.node APIs
  • 10. Copyright © 2016 M/Gateway Developments Ltd ewd-document-store - JavaScript Abstraction of Global Storage https://github.com/robtweed/ewd-document-store Layered on top of the basic cache.node APIs Loaded automatically into QEWD workers
  • 11. Copyright © 2016 M/Gateway Developments Ltd ewd-document-store - JavaScript Abstraction of Global Storage https://github.com/robtweed/ewd-document-store Layered on top of the basic cache.node APIs Loaded automatically into QEWD workers Made accessible in QEWD by this.documentStore
  • 12. Copyright © 2016 M/Gateway Developments Ltd ewd-document-store - JavaScript Abstraction of Global Storage https://github.com/robtweed/ewd-document-store Layered on top of the basic cache.node APIs Loaded automatically into QEWD workers Made accessible in QEWD by this.documentStore Can also be used standalone for testing and debugging
  • 13. Copyright © 2016 M/Gateway Developments Ltd ewd-document-store - JavaScript Abstraction of Global Storage Use in a test harness: See example in: https://github.com/robtweed/ewd-document-store/blob/master/lib/tests/CacheStandalone.js
  • 14. Copyright © 2016 M/Gateway Developments Ltd Edit CacheStandalone.js var DocumentStore = require('ewd-document-store'); var interface = require('cache'); var db = new interface.Cache(); console.log('db: ' + JSON.stringify(db)); // Change these parameters to match your GlobalsDB or Cache system: var ok = db.open({ path: '/opt/cache/mgr', username: '_SYSTEM', password: 'SYS', namespace: 'USER' }); console.log('ok: ' + JSON.stringify(ok)); var documentStore = new DocumentStore(db); console.log(db.version()); var rob = new documentStore.DocumentNode('rob');
  • 15. Copyright © 2016 M/Gateway Developments Ltd Edit CacheStandalone.js var DocumentStore = require('ewd-document-store'); var interface = require('cache'); var db = new interface.Cache(); console.log('db: ' + JSON.stringify(db)); // Change these parameters to match your GlobalsDB or Cache system: var ok = db.open({ path: 'C:InterSystemsCache2015-2mgr', username: '_SYSTEM', password: 'SYS', namespace: 'USER' }); console.log('ok: ' + JSON.stringify(ok)); var documentStore = new DocumentStore(db); console.log(db.version()); var rob = new documentStore.DocumentNode('rob');
  • 16. Copyright © 2016 M/Gateway Developments Ltd Save as C:qewddocStoreTest.js var DocumentStore = require('ewd-document-store'); var interface = require('cache'); var db = new interface.Cache(); console.log('db: ' + JSON.stringify(db)); // Change these parameters to match your GlobalsDB or Cache system: var ok = db.open({ path: 'C:InterSystemsCache2015-2mgr', username: '_SYSTEM', password: 'SYS', namespace: 'USER' }); console.log('ok: ' + JSON.stringify(ok)); var documentStore = new DocumentStore(db); console.log(db.version()); var rob = new documentStore.DocumentNode('rob');
  • 17. Copyright © 2016 M/Gateway Developments Ltd Version for use with GT.M var DocumentStore = require('ewd-document-store'); var interface = require('nodem'); var db = new interface.Gtm(); console.log('db: ' + JSON.stringify(db)); var ok = db.open(); console.log('ok: ' + JSON.stringify(ok)); var documentStore = new DocumentStore(db); console.log(db.version()); var rob = new documentStore.DocumentNode('rob');
  • 18. Copyright © 2016 M/Gateway Developments Ltd Version for use with ewd-redis-globals var DocumentStore = require('ewd-document-store'); var interface = require('ewd-redis-globals'); var db = new interface(); console.log('db: ' + JSON.stringify(db)); var ok = db.open(); console.log('ok: ' + JSON.stringify(ok)); var documentStore = new DocumentStore(db); console.log(db.version()); var rob = new documentStore.DocumentNode('rob');
  • 19. Copyright © 2016 M/Gateway Developments Ltd Run it cd qewd (or cd /qewd ) node docStoreTest
  • 20. Copyright © 2016 M/Gateway Developments Ltd Run it cd ewd3 node docStoreTest It runs a set of examples using DocumentNode objects You can use it as the basis of your own test harness
  • 21. Copyright © 2016 M/Gateway Developments Ltd Adapting your own test harness var DocumentStore = require('ewd-document-store'); var interface = require('cache'); var db = new interface.Cache(); var ok = db.open({ path: 'C:InterSystemsCache2015-2mgr', username: '_SYSTEM', password: 'SYS', namespace: 'USER' }); var documentStore = new DocumentStore(db); // delete and replace everything from this point onwards // documentStore provides you with the abstracted interface to your database // use this to try out the following examples for yourself // simply replace this.documentStore with documentStore
  • 22. Copyright © 2016 M/Gateway Developments Ltd The DocumentNode Object
  • 23. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new documentStore.DocumentNode(name, subscripts); when using standalone test harness
  • 24. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode(name, subscripts); when using QEWD
  • 25. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode(name, subscripts); Represents a node within a document store hierarchy May or may not physically exist at this point ie this does NOT create a node
  • 26. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode(name, subscripts); Represents a node within a document's hierarchy May or may not physically exist at this point ie this does NOT create a node Creates an instance of an object that represents that node, with a set of methods and properties to manipulate and access that node
  • 27. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2")
  • 28. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2';
  • 29. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2'; get: var x = dnode.value;
  • 30. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2'; get: var x = dnode.value; value is a read/write property
  • 31. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2'; get: var x = dnode.value; delete: dnode.delete();
  • 32. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2'; get: var x = dnode.value; delete: dnode.delete(); Note: delete will also delete any lower-level DocumentNodes in the underlying Global Storage tree
  • 33. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); represents myDoc("d","e2") create: dnode.value = 'foo2'; get: var x = dnode.value; delete: dnode.delete(); exists?: var exists = dnode.exists; // true | false
  • 34. Copyright © 2016 M/Gateway Developments Ltd myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3" var dnode = new this.documentStore.DocumentNode('myDoc', ['d']);
  • 35. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d']); dnode.hasChildren // true dnode.hasValue // false dnode.exists // true myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3"
  • 36. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); dnode.hasChildren // true dnode.hasValue // false dnode.exists // true myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3"
  • 37. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f3']); dnode.hasChildren // false dnode.hasValue // true dnode.exists // true myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3"
  • 38. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f4']); dnode.hasChildren // false dnode.hasValue // false dnode.exists // false Even though the node doesn’t physically exist, you can define a DocumentNode Object for it myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3"
  • 39. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2', 'f3']); dnode.name // f3 Node Name === last global subscript dnode.parent // myDoc("d","e2") myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3" Returns a DocumentNode Object
  • 40. Copyright © 2016 M/Gateway Developments Ltd var dnode = new this.documentStore.DocumentNode('myDoc', ['d', 'e2']); dnode.firstChild // myDoc("d","e2","f1") dnode.lastChild // myDoc("d","e2","f3") dnode.previousSibling // myDoc("d","e1") dnode.nextSibling // undefined myDoc("a")=123 myDoc("b","c1")="foo" myDoc("b","c2")="foo2" myDoc("d","e1","f1")="bar1" myDoc("d","e1","f2")="bar2" myDoc("d","e2","f1")="bar1" myDoc("d","e2","f2")="bar2" myDoc("d","e2","f3")="bar3" DocumentNode Objects
  • 41. Copyright © 2016 M/Gateway Developments Ltd DocumentNode Object • We’ll further explore it in subsequent parts of this course • For more / additional information: – http://gradvs1.mgateway.com/download/ewd-document-store.pdf