Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//dependencies - this is just nice to have here - a list of known dependencies required by the function
// bucket alias <Users_Bucket>
//--------------------------------------------------------------------
//local aliases - create these so that you can test your code locally
//then comment them out when you upload to the server
var Users_Bucket = {};
var log = console.log;
//--------------------------------------------------------------------
//all top level entities must be function declarations
//so this is illegal
//var cstr = function (){}
//this is fine
function cstr(){}
function OnUpdate(doc, meta) {
//the eventing script system doesn't throw a lot of guided errors
//I'd suggest wrapping everything everything in a trycatch
try{
log('docid', meta.id);
log('doc', doc);
//...
}catch(e){
log(e);
}
}function OnDelete(meta) {
}
//meta is obviously produced when the event is triggered, so just fake it to test locally
// var testData = require('../testdata/getErrors_testdata');
// var meta = {cas: 1582920675004055600,
// id: "user_profile::IDM800027799"}
// }
// OnUpdate(testData.IDM800646917.Users_Bucket,meta);