Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro REST service using MongoDB as backend Two basic operations (to simplify) – Update attributes in entities (e.g. update the “speed” attribute in the.

Similar presentations


Presentation on theme: "Intro REST service using MongoDB as backend Two basic operations (to simplify) – Update attributes in entities (e.g. update the “speed” attribute in the."— Presentation transcript:

1 Intro REST service using MongoDB as backend Two basic operations (to simplify) – Update attributes in entities (e.g. update the “speed” attribute in the “Car1” entity) – Subscribe to changes in a given attribute on a given entity, so when an update of it occurs, then a notification to a given URL is sent MongoDB REST sesrvice

2 Update MongoDB REST sesrvice “Update the Car1 speed to 80 km/h” Entities are stored in the ‘entities’ collection: { "_id": "Car1", "attrs": [ { "name": "speed", "value": "80" } ] } Entities are stored in the ‘entities’ collection: { "_id": "Car1", "attrs": [ { "name": "speed", "value": "80" } ] }

3 Subscription MongoDB REST sesrvice “I want to receive a notification on http://notify.me each time any Car speed changes” Subscriptions are stored in the ‘csubs’ collection: { "_id": ObjectId("5149fd46f0075f83a4ca0300"), "reference": "http://notify.me", "entity": "Car.*", "attr": "speed" } Subscriptions are stored in the ‘csubs’ collection: { "_id": ObjectId("5149fd46f0075f83a4ca0300"), "reference": "http://notify.me", "entity": "Car.*", "attr": "speed" }

4 Update triggering subscription (“the problem”) MongoDB REST sesrvice “Update the Car1 speed to 85 km/h” In order to know which subscriptions are triggered by this update, a query on the “csubs” collection has to be done using “Car1” for the lookup. However, we have the regular expression stored in csubs (regex is not in the query!) Currently we use {$where: “\"Car1\".match(this.entity)" }, which is not recommended by MongoDB documentation. Reverse regex will solve this problem in a smart way: {entity: {$regexApply: {“Car1”}}} In order to know which subscriptions are triggered by this update, a query on the “csubs” collection has to be done using “Car1” for the lookup. However, we have the regular expression stored in csubs (regex is not in the query!) Currently we use {$where: “\"Car1\".match(this.entity)" }, which is not recommended by MongoDB documentation. Reverse regex will solve this problem in a smart way: {entity: {$regexApply: {“Car1”}}} (See https://jira.mongodb.org/browse/SERVER-13902 for more details on $regexApply)https://jira.mongodb.org/browse/SERVER-13902


Download ppt "Intro REST service using MongoDB as backend Two basic operations (to simplify) – Update attributes in entities (e.g. update the “speed” attribute in the."

Similar presentations


Ads by Google