In this example, we will match candidates (structured as 'Cand') with job offers (structured as 'Jobs') by considering the intersection of skills, represented as arrays such as finance, management, and programming. The candidate's skills are stored in 'cand_skills,' while the required skills (functions) for the job are stored in 'job_functions.' The matching result will be saved in the 'Job' object, specifically in the 'candidate_ids' field.
Here we use the following functions:
Standard JS method
Standard JS method
Content within the :
// Scenario processes objects from Jobs
DirectualEngine.addEventListener(AppEvents.START, function(context){
var candidates = $D.eval("{{candidates_ids}}")
var functions = $D.eval("{{job_functions}}")
var id = $D.eval("{{id}}")
var matchCand = []
if (candidates) {
candidates.split(",").forEach(function(cand) {
var candSkills = $D.store.get("Cand", cand, {fields: ["cand_skills"]});
if ($D.arrayContainsAny(candSkills, functions)) {
matchCand = $D.concat(matchCand,cand)
}
})
}
$D.store.save("Jobs", {"id": id, "candidate_ids": matchCand }, false)
return true;
});
Example 2: Composing JSON with Custom Property Names
For instance, if you have structures for 'Authors' and 'Books' and want to compose JSON like this: