Skip to content
Snippets Groups Projects
example_function.js 1.13 KiB
Newer Older
Franky Begue's avatar
Franky Begue committed
//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);