Güncellenmesi Öyle benzeyen bir anket tablo var. Şu anda, böyle güncelleştirmeyi çalıştırıyorum: değer çiftleri:RethinkDB iç içe dizi
function saveScore(obj){
var dfd = q.defer();
var survey = surveys.get(obj.survey_id);
survey
.pluck({ clients: 'contacts' })
.run()
.then(results => {
results.clients.forEach((item, outerIndex) => {
item.contacts.forEach((item, index, array) => {
if(Number(item.contact_id) === Number(obj.contact_id)) {
array[index].score = obj.score;
console.log(outerIndex, index);
}
});
});
return survey.update(results).run()
})
.then(results => dfd.resolve(results))
.catch(err => dfd.resolve(err));
return dfd.promise;
};
Ben update yönteme baktığımızda, bu iç içe anahtar nasıl güncelleneceğini belirtir. Bununla birlikte, bir dizideki tek bir öğeyi güncelleştirmek için herhangi bir örnek bulamıyorum.
İç içe geçmiş bir dizideki öğeleri güncellemek için daha iyi ve umarız daha temiz bir yol var mı?