这是路径https://code.firebaseio.com/products2上的数据结构
现在我想在 products/2586/Variants 上添加新条目。说条目是 112:真
我写了这个函数。
$scope.AddProductVariant2 = function(Product, Variant) {
//ProductService.AddProductVariant (Product, Variant);
var key = Product.ProductID;
var productRef = firebase.database().ref();
var updates = {};
var variant = {};
variant[Variant.VariantID] = true;
updates['products2/' + key + '/' + 'Variants'] = variant;
/*
firebase.database().ref('products2/' + key + '/' + 'Variants').set({
variant
});
*/
return productRef.update(updates);
};
但它正在删除所有旧条目。
如何在不触及旧条目的情况下添加新条目?