I would suggest not preventing duplication of "morals" on the client side; it will be too comprehensive as you described. You can do two things:
You can prevent duplication by structuring your database as follows:
{
"likes": {
"user1Key": {
"objectLikedKey1": true,
"objectLikedKey2": true
...
}
}
}
Thus, the data structure will prevent duplication by default. Think of it as a set!
If your database is structured differently and for some reason you need it, you can use the rule to prevent duplication. (I'll just take a random structure here so you can get this idea)
{
"rules": {
".read": true,
"userLikes": {
"$user": {
".write": "!data.exists()"
}
}
}
}
This means that you can only write to the database if the data does not already exist.
Update:
, , ""
{
"objects": {
"object1Key": {
"user1Key": true,
"user2Key": true
...
"timestamp": "2017-01-01 12:00:00 +0000"
}
}
}
(1) , . , , .
- Facebook- , , , . , - , ( 5 10) , . , , , , , , , .
, , . , "" , , , , Firebase .
:
- , , , , :
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let lastElement = yourDataSource.count - 1
if indexPath.row == lastElement {
}
}
-Pagination - , , , , , ( , , ), . queryOrderedByChild(), queryStartingAtValue() queryLimitedToFirst(), , , !