Created
August 2, 2017 01:03
-
-
Save michael-mckenna/312e0eea9449ef0c47700a943c1e7fc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logs: | |
Starting function | |
Changes in realm at: /globalUsers | |
Changes in Model: GlobalUser | |
- object inserted at position 4 : RealmObject { username: 'test', email: '[email protected]' } | |
Code: | |
console.log("Starting function"); | |
// add your initialization code here | |
module.exports = function(changeEvent) { | |
// event handler code goes here | |
console.log("Changes in realm at:", changeEvent.path); | |
var realm = changeEvent.realm; | |
for (var className in changeEvent.changes) { | |
var changes = changeEvent.changes[className]; | |
var objects = realm.objects(className); | |
console.log("Changes in Model:", className); | |
var i, pos; | |
for (i = 0; i < changes.insertions.length; i++) { | |
pos = changes.insertions[i]; | |
console.log("- object inserted at position", pos, ":", objects[pos]); | |
} | |
for (i = 0; i < changes.modifications.length; i++) { | |
pos = changes.modifications[i]; | |
console.log("- object modified at position", pos, ":", objects[pos]); | |
} | |
for (i = 0; i < changes.deletions.length; i++) { | |
pos = changes.deletions[i]; | |
console.log("- object deleted at position", pos); | |
} | |
} | |
console.log(""); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment