SlideShare a Scribd company logo
Copyright ยฉ 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 26
JavaScript Abstraction of Global Storage:
Event-Driven Indexing
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Indexing
โ€ข When a document node is created,
changed or deleted, we may want to
maintain a corresponding set of index
document nodes
โ€ข How can this be done in a modular and
automatically-invoked way?
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Indexing
โ€ข When a document node is created,
changed or deleted, we may want to
maintain a corresponding set of index
document nodes
โ€ข How can this be done in a modular and
automatically-invoked way?
โ€“ Events
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Events
โ€ข Emitted automatically by:
โ€“ value property (when used to set/change a
value)
โ€“ setDocument() method (for each node
created)
โ€“ increment() method
โ€“ delete() method
โ€ข Allows you to write handlers to maintain
indices
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Events
โ€ข beforeSet
โ€ข afterSet
โ€ข beforeDelete
โ€ข afterDelete
โ€“ You'll probably use the after* events most
frequently
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
โ€ข this.documentStore.on(eventName, function(obj) {..});
โ€ข eg:
this.documentStore.on('afterSet', function(nodeObj) {
// do something with the changed node
});
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
โ€ข this.documentStore.on(eventName, function(obj) {..});
โ€ข eg:
this.documentStore.on('afterSet', function(nodeObj) {
// do something with the changed node
});
Tells you what node was changed,
what value it had previously (if any)
and what new value it has now
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
Example of afterSet node object
{
"documentName":"CacheTempEWDSession",
"path":["session","72","foo"],
"before":{
"value":"bar",
"exists":true
},
"value":"bar"
}
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
{
"documentName":"CacheTempEWDSession",
"path":["session","72","foo"],
"before":{
"value":"bar",
"exists":true
},
"value":"bar"
}
Tells you the DocumentNode
that may need indexing / re-indexing
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
{
"documentName":"CacheTempEWDSession",
"path":["session","72","foo"],
"before":{
"value":"bar",
"exists":true
},
"value":"bar"
}
Tells you the previous contents,
if any, of the DocumentNode, prior
to the afterSet event
Copyright ยฉ 2016 M/Gateway Developments Ltd
Document Store Event Handling
{
"documentName":"CacheTempEWDSession",
"path":["session","72","foo"],
"before":{
"value":"bar",
"exists":true
},
"value":"bar"
}
Tells you the new value of the
DocumentNode, as a result of
the afterSet event
Copyright ยฉ 2016 M/Gateway Developments Ltd
Where to handle Document Store Events?
โ€ข Your QEWD application-specific back-end
handler module
โ€“ Use its optional init() function
โ€ข If defined in your module, this function is invoked
when the module is initially loaded by a worker
process
โ€ข You can define the handlers you need within this
function
โ€ข Filter the document names you're interested in
indexing within your application module
Copyright ยฉ 2016 M/Gateway Developments Ltd
Handling Document Store
Events
โ€ข eg C:qewdnode_modulesdemo1.js
module.exports = {
init: function() {
this.documentStore.on('afterSet', function(docNode) {
console.log('*** afterSet event triggered by ' + JSON.stringify(docNode));
});
},
handlers: {
testButton: function(messageObj, session, send, finished) {
session.data.$('foo').value = 'bar';
send({
type: 'intermediate',
foo: 'bar',
date: new Date().toString()
});
finished({
ok: 'testButton message was processed successfully!'
});
}
};
Copyright ยฉ 2016 M/Gateway Developments Ltd
Handling Document Store
Events
โ€ข eg C:qewdnode_modulesdemo1.js
module.exports = {
init: function() {
this.documentStore.on('afterSet', function(docNode) {
if (docNode.documentName === 'myDoc') {
// delete previous index document node
// create new index node
// remember that this will, itself, invoke more events for index document nodes!
}
});
},
handlers: {
// etcโ€ฆ
}
};

More Related Content

What's hot (20)

PDF
Nginx: Accelerate Rails, HTTP Tricks
Adam Wiggins
ย 
PPTX
NGINX High-performance Caching
NGINX, Inc.
ย 
PPTX
Varnish intro
Boyan Borisov
ย 
PDF
Memcached Study
nam kwangjin
ย 
PPTX
Using memcache to improve php performance
Sudar Muthu
ย 
PPTX
Reverse proxy & web cache with NGINX, HAProxy and Varnish
El Mahdi Benzekri
ย 
PPTX
Caching
Nascenia IT
ย 
PPTX
Fluent 2012 v2
Shalendra Chhabra
ย 
PPTX
Usenix LISA 2012 - Choosing a Proxy
Leif Hedstrom
ย 
KEY
Performance Tuning - MuraCon 2012
eballisty
ย 
PDF
Wordpress optimization
Almog Baku
ย 
PDF
Varnish Cache
Mike Willbanks
ย 
PPTX
JSR107 Come, Code, Cache, Compute!
Payara
ย 
PPTX
Memcached
Shrawan Kumar Nirala
ย 
PDF
Scaling WordPress On A Small Budget
Brecht Ryckaert
ย 
PDF
Varnish - PLNOG 4
Leszek Urbanski
ย 
PDF
Varnish Configuration Step by Step
Kim Stefan Lindholm
ย 
PDF
Introduction to CQ5
Michele Mostarda
ย 
PPTX
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Fastly
ย 
ODP
Cassandra as Memcache
Edward Capriolo
ย 
Nginx: Accelerate Rails, HTTP Tricks
Adam Wiggins
ย 
NGINX High-performance Caching
NGINX, Inc.
ย 
Varnish intro
Boyan Borisov
ย 
Memcached Study
nam kwangjin
ย 
Using memcache to improve php performance
Sudar Muthu
ย 
Reverse proxy & web cache with NGINX, HAProxy and Varnish
El Mahdi Benzekri
ย 
Caching
Nascenia IT
ย 
Fluent 2012 v2
Shalendra Chhabra
ย 
Usenix LISA 2012 - Choosing a Proxy
Leif Hedstrom
ย 
Performance Tuning - MuraCon 2012
eballisty
ย 
Wordpress optimization
Almog Baku
ย 
Varnish Cache
Mike Willbanks
ย 
JSR107 Come, Code, Cache, Compute!
Payara
ย 
Memcached
Shrawan Kumar Nirala
ย 
Scaling WordPress On A Small Budget
Brecht Ryckaert
ย 
Varnish - PLNOG 4
Leszek Urbanski
ย 
Varnish Configuration Step by Step
Kim Stefan Lindholm
ย 
Introduction to CQ5
Michele Mostarda
ย 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Fastly
ย 
Cassandra as Memcache
Edward Capriolo
ย 

Viewers also liked (20)

PDF
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 25: Document Database Capabilities
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 21: Persistent JavaScript Objects
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 19: The cache.node APIs
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 20: The DocumentNode Object
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 30: Modularising QEWD Applications
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 27: The QEWD Session
Rob Tweed
ย 
PPT
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 16: QEWD Services
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 29: Running QEWD as a Service
Rob Tweed
ย 
PPT
EWD 3 Training Course Part 42: The QEWD Docker Appliance
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 35: QEWD Session Locking
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
Rob Tweed
ย 
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
Rob Tweed
ย 
EWD 3 Training Course Part 25: Document Database Capabilities
Rob Tweed
ย 
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
Rob Tweed
ย 
EWD 3 Training Course Part 21: Persistent JavaScript Objects
Rob Tweed
ย 
EWD 3 Training Course Part 19: The cache.node APIs
Rob Tweed
ย 
EWD 3 Training Course Part 20: The DocumentNode Object
Rob Tweed
ย 
EWD 3 Training Course Part 30: Modularising QEWD Applications
Rob Tweed
ย 
EWD 3 Training Course Part 27: The QEWD Session
Rob Tweed
ย 
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
Rob Tweed
ย 
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
Rob Tweed
ย 
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
Rob Tweed
ย 
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
Rob Tweed
ย 
EWD 3 Training Course Part 16: QEWD Services
Rob Tweed
ย 
EWD 3 Training Course Part 29: Running QEWD as a Service
Rob Tweed
ย 
EWD 3 Training Course Part 42: The QEWD Docker Appliance
Rob Tweed
ย 
EWD 3 Training Course Part 35: QEWD Session Locking
Rob Tweed
ย 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
ย 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
ย 
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
Rob Tweed
ย 
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
Rob Tweed
ย 
Ad

Similar to EWD 3 Training Course Part 26: Event-driven Indexing (20)

PDF
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Dropsolid
ย 
PDF
Applied Machine learning using H2O, python and R Workshop
Avkash Chauhan
ย 
PDF
Importing Data into Neo4j quickly and easily - StackOverflow
Neo4j
ย 
PPTX
Mahout Introduction BarCampDC
Drew Farris
ย 
PDF
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
ย 
PDF
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2
ย 
PDF
Building an API layer for C* at Coursera
Daniel Jin Hao Chia
ย 
PDF
Java/Scala Lab: ะ‘ะพั€ะธั ะขั€ะพั„ะธะผะพะฒ - ะžะฑะถะธะณะฐัŽั‰ะฐั Big Data.
GeeksLab Odessa
ย 
PPTX
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
walk2talk srl
ย 
PDF
Saving Money by Optimizing Your Cloud Add-On Infrastructure
Atlassian
ย 
PPT
HTML5_elementos nuevos integrados ahora
mano21161
ย 
PPTX
Conceptos bรกsicos. Seminario web 2: Su primera aplicaciรณn MongoDB
MongoDB
ย 
PPTX
Kite SDK: Working with Datasets
Cloudera, Inc.
ย 
PPTX
MSDN - Converting an existing ASP.NET application to Windows Azure
Maarten Balliauw
ย 
PPTX
Introducing DataWave
Data Works MD
ย 
PPTX
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
ย 
PPTX
Running Vue Storefront in production (PWA Magento webshop)
Vendic Magento, PWA & Marketing
ย 
PDF
WordPress Cafรฉ: Using WordPress as a Framework
Exove
ย 
PPTX
REST meets Semantic Web
Steve Speicher
ย 
PDF
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
mfrancis
ย 
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Dropsolid
ย 
Applied Machine learning using H2O, python and R Workshop
Avkash Chauhan
ย 
Importing Data into Neo4j quickly and easily - StackOverflow
Neo4j
ย 
Mahout Introduction BarCampDC
Drew Farris
ย 
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
ย 
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2
ย 
Building an API layer for C* at Coursera
Daniel Jin Hao Chia
ย 
Java/Scala Lab: ะ‘ะพั€ะธั ะขั€ะพั„ะธะผะพะฒ - ะžะฑะถะธะณะฐัŽั‰ะฐั Big Data.
GeeksLab Odessa
ย 
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
walk2talk srl
ย 
Saving Money by Optimizing Your Cloud Add-On Infrastructure
Atlassian
ย 
HTML5_elementos nuevos integrados ahora
mano21161
ย 
Conceptos bรกsicos. Seminario web 2: Su primera aplicaciรณn MongoDB
MongoDB
ย 
Kite SDK: Working with Datasets
Cloudera, Inc.
ย 
MSDN - Converting an existing ASP.NET application to Windows Azure
Maarten Balliauw
ย 
Introducing DataWave
Data Works MD
ย 
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
ย 
Running Vue Storefront in production (PWA Magento webshop)
Vendic Magento, PWA & Marketing
ย 
WordPress Cafรฉ: Using WordPress as a Framework
Exove
ย 
REST meets Semantic Web
Steve Speicher
ย 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
mfrancis
ย 
Ad

More from Rob Tweed (13)

PDF
QEWD Update
Rob Tweed
ย 
PPT
Data Persistence as a Language Feature
Rob Tweed
ย 
PPT
LNUG: Having Your Node.js Cake and Eating It Too
Rob Tweed
ย 
PPT
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
Rob Tweed
ย 
PPT
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
Rob Tweed
ย 
PPT
QEWD.js, JSON Web Tokens & MicroServices
Rob Tweed
ย 
PPT
QEWD.js: Have your Node.js Cake and Eat It Too
Rob Tweed
ย 
PPT
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
Rob Tweed
ย 
PDF
qewd-ripple: The Ripple OSI Middle Tier
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
Rob Tweed
ย 
PDF
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
Rob Tweed
ย 
QEWD Update
Rob Tweed
ย 
Data Persistence as a Language Feature
Rob Tweed
ย 
LNUG: Having Your Node.js Cake and Eating It Too
Rob Tweed
ย 
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
Rob Tweed
ย 
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
Rob Tweed
ย 
QEWD.js, JSON Web Tokens & MicroServices
Rob Tweed
ย 
QEWD.js: Have your Node.js Cake and Eat It Too
Rob Tweed
ย 
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
Rob Tweed
ย 
qewd-ripple: The Ripple OSI Middle Tier
Rob Tweed
ย 
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
Rob Tweed
ย 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
Rob Tweed
ย 
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
Rob Tweed
ย 
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
Rob Tweed
ย 

Recently uploaded (20)

PPTX
Operations Profile SPDX_Update_20250711_Example_05_03.pptx
Shane Coughlan
ย 
PPTX
API DOCUMENTATION | API INTEGRATION PLATFORM
philipnathen82
ย 
PPTX
PCC IT Forum 2025 - Legislative Technology Snapshot
Gareth Oakes
ย 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
ย 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
ย 
PPTX
Chess King 25.0.0.2500 With Crack Full Free Download
cracked shares
ย 
PPTX
MiniTool Partition Wizard Crack 12.8 + Serial Key Download Latest [2025]
filmoracrack9001
ย 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
ย 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
ย 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
ย 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
ย 
PDF
Australian Enterprises Need Project Service Automation
Navision India
ย 
PDF
chapter 5.pdf cyber security and Internet of things
PalakSharma980227
ย 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
ย 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
ย 
PDF
AI Image Enhancer: Revolutionizing Visual Qualityโ€
docmasoom
ย 
PDF
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
ย 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
ย 
PPTX
Cutting Optimization Pro 5.18.2 Crack With Free Download
cracked shares
ย 
PDF
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
ย 
Operations Profile SPDX_Update_20250711_Example_05_03.pptx
Shane Coughlan
ย 
API DOCUMENTATION | API INTEGRATION PLATFORM
philipnathen82
ย 
PCC IT Forum 2025 - Legislative Technology Snapshot
Gareth Oakes
ย 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
ย 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
ย 
Chess King 25.0.0.2500 With Crack Full Free Download
cracked shares
ย 
MiniTool Partition Wizard Crack 12.8 + Serial Key Download Latest [2025]
filmoracrack9001
ย 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
ย 
Brief History of Python by Learning Python in three hours
adanechb21
ย 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
ย 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
ย 
Australian Enterprises Need Project Service Automation
Navision India
ย 
chapter 5.pdf cyber security and Internet of things
PalakSharma980227
ย 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
ย 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
ย 
AI Image Enhancer: Revolutionizing Visual Qualityโ€
docmasoom
ย 
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
ย 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
ย 
Cutting Optimization Pro 5.18.2 Crack With Free Download
cracked shares
ย 
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
ย 

EWD 3 Training Course Part 26: Event-driven Indexing

  • 1. Copyright ยฉ 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 26 JavaScript Abstraction of Global Storage: Event-Driven Indexing Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Indexing โ€ข When a document node is created, changed or deleted, we may want to maintain a corresponding set of index document nodes โ€ข How can this be done in a modular and automatically-invoked way?
  • 3. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Indexing โ€ข When a document node is created, changed or deleted, we may want to maintain a corresponding set of index document nodes โ€ข How can this be done in a modular and automatically-invoked way? โ€“ Events
  • 4. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Events โ€ข Emitted automatically by: โ€“ value property (when used to set/change a value) โ€“ setDocument() method (for each node created) โ€“ increment() method โ€“ delete() method โ€ข Allows you to write handlers to maintain indices
  • 5. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Events โ€ข beforeSet โ€ข afterSet โ€ข beforeDelete โ€ข afterDelete โ€“ You'll probably use the after* events most frequently
  • 6. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling โ€ข this.documentStore.on(eventName, function(obj) {..}); โ€ข eg: this.documentStore.on('afterSet', function(nodeObj) { // do something with the changed node });
  • 7. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling โ€ข this.documentStore.on(eventName, function(obj) {..}); โ€ข eg: this.documentStore.on('afterSet', function(nodeObj) { // do something with the changed node }); Tells you what node was changed, what value it had previously (if any) and what new value it has now
  • 8. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling Example of afterSet node object { "documentName":"CacheTempEWDSession", "path":["session","72","foo"], "before":{ "value":"bar", "exists":true }, "value":"bar" }
  • 9. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling { "documentName":"CacheTempEWDSession", "path":["session","72","foo"], "before":{ "value":"bar", "exists":true }, "value":"bar" } Tells you the DocumentNode that may need indexing / re-indexing
  • 10. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling { "documentName":"CacheTempEWDSession", "path":["session","72","foo"], "before":{ "value":"bar", "exists":true }, "value":"bar" } Tells you the previous contents, if any, of the DocumentNode, prior to the afterSet event
  • 11. Copyright ยฉ 2016 M/Gateway Developments Ltd Document Store Event Handling { "documentName":"CacheTempEWDSession", "path":["session","72","foo"], "before":{ "value":"bar", "exists":true }, "value":"bar" } Tells you the new value of the DocumentNode, as a result of the afterSet event
  • 12. Copyright ยฉ 2016 M/Gateway Developments Ltd Where to handle Document Store Events? โ€ข Your QEWD application-specific back-end handler module โ€“ Use its optional init() function โ€ข If defined in your module, this function is invoked when the module is initially loaded by a worker process โ€ข You can define the handlers you need within this function โ€ข Filter the document names you're interested in indexing within your application module
  • 13. Copyright ยฉ 2016 M/Gateway Developments Ltd Handling Document Store Events โ€ข eg C:qewdnode_modulesdemo1.js module.exports = { init: function() { this.documentStore.on('afterSet', function(docNode) { console.log('*** afterSet event triggered by ' + JSON.stringify(docNode)); }); }, handlers: { testButton: function(messageObj, session, send, finished) { session.data.$('foo').value = 'bar'; send({ type: 'intermediate', foo: 'bar', date: new Date().toString() }); finished({ ok: 'testButton message was processed successfully!' }); } };
  • 14. Copyright ยฉ 2016 M/Gateway Developments Ltd Handling Document Store Events โ€ข eg C:qewdnode_modulesdemo1.js module.exports = { init: function() { this.documentStore.on('afterSet', function(docNode) { if (docNode.documentName === 'myDoc') { // delete previous index document node // create new index node // remember that this will, itself, invoke more events for index document nodes! } }); }, handlers: { // etcโ€ฆ } };