How to remove all RiskScore?


#1

RiskScore.removeAll() returns an error


#2

Credit: Yaroslav Buzko

function map(batch, objs, job) { 
  objs.each(function(rsh) { 
	var log=C3.logger("RemoveRiskScores");
    try {
		RiskScore.removeAll(Filter.eq('parent.id',rsh.id))
	} catch(err){log.error(err);}
  }); 
}

var spec = JSMapReduceSpec.make({
	targetType: RiskScoreHistory,
	include: "id",
	order:"id",
	limit: -1,
	batchSize: 100,
	map: map
});

var mrj = JS.mapReduce(spec);
mrj.status();