no_of_orders
フィールドに保存できる最大整数を2
に制限するルールを追加したいとします。 OrderSchedule
ドキュメントデータは、私が開発しているアプリを介してあらかじめ設定されています。Firebase DBにルールを追加する必要がある
ここにはjsonExport
というデータがあります。
{
"OrderSchedule" : {
"13-Oct-2016" : {
"13:00 - 14:00" : {
"no_of_orders" : 4
}
}
},
"Orders" : {
"-KTpIn4HeuDBDliCnTSA" : {
"car_Model" : "Van",
"date_Created" : 1476212105,
"date_Scheduled" : "13-Oct-2016",
"service_Type" : "Shine",
"status" : "Scheduled",
"time_Scheduled" : "13:00 - 14:00",
"uid" : "sms|57f7b267e618d33da23e65ce"
},
"-KTpJ6BREc695pv4Ue6s" : {
"car_Model" : "SUV",
"date_Created" : 1476212188,
"date_Scheduled" : "13-Oct-2016",
"service_Type" : "Detailed",
"status" : "Scheduled",
"time_Scheduled" : "13:00 - 14:00",
"uid" : "sms|57f7b267e618d33da23e65ce"
},
"users" : {
"sms|57f7b267e618d33da23e65ce" : {
"created_at" : 1475868493,
"email" : "[email protected]",
"phone" : "+0000000000",
"username" : "balouza"
},
"sms|57fa9701e618d33da240efa5" : {
"created_at" : 1476040501,
"email" : "[email protected]",
"phone" : "+00000000000",
"username" : "bolzo"
}
}
}
セキュリティルール:
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"max": {
".write": "auth != null"
},
".OrderSchedule": {
"$date": {
"$timeSlot": {
"no_of_orders": {
".validate": "newData.val() <= root.child('max').val()"
}
}
}
}
}
}
databaseJSONツリーをスニペットではなくテキストとして提供します。 – Dravidian
妥当な要件のようです。どうしたの? –
@Dravidianここに行きます。 –