我想要创建两个节点,
通常在SQL中我们使用id_region(PRIMARY KEY), name_region
创建表区域,我们使用id_cities (PRIMARY KEY), name_cities,id_region
创建表格城市,所以我们使用其ID来引用区域表。
如何在firebase数据库上添加点。?
答案 0 :(得分:2)
这应该适合你。
root: {
cities: {
$city_1: {
region: $region_1
},
$city_2: {
region: $region_1
}
},
regions: {
$region_1: {
cities: {
$city_1: true, // This node can have any value really just as long as the key refers to $city_1
$city_2: true // Same
}
}
}
}