Cloud function updating count for record id on Skygear Cloud


#1

Hello, i have a record like :
Pahtologie : *title, *content,*like, *comment
Comment is referencer at the table pathologie, but my concern is to increment the like of pathologie_id every time we comment in the table with skygear function. Thanks


#2
skygearCloud.afterSave('comment', function(record, original, pool, options) {
	if (!original) {
		pool.query(`UPDATE pathologie SET like = like + 1, _updated_at = CURRENT_TIMESTAMP WHERE '_id' = '${record.pathologie_id}'`, function(err, result) {
			if (err) {
				console.log(err);
				return;
			}
			console.log(result);
		})

	}
    return;
}, {
    async: false
}

Can i do like this ?


#3

Yes. You can do it via SQL or SkyRecord Query.


#4

I can’t deploy because of dashboard


#5

The status icon was down but it should not affect production nodes. It should have been back online now.