title: Firebase - Managing user likes in an efficient way - Swift
body: <p>I have an application where a user can like things in the app, it is for obvious reasons that a user shouldnt be able to like something twice. To make sure of this, when a user likes something, I store the key of the article in a list on the database. The problem is what is the most efficient way when the table view is loading to check if the user has liked the article already.</p>
  
  <p>But after that I need advice, the way I see it I have two ways I can do this. </p>
  
  <ol>
  <li><p>I can load the entire list when the app starts and then when the table view loads I can check if the article key is in the list of already likes keys. (This is what I am leaning toward) The only problem with this is when a user has liked say 1000 things then everytime the app starts it will have to download 1000 rows from Firebase which is a lot, the other problem means that the articles can't start loading until this query is done.</p></li>
  <li><p>Pass the article key into the cell and then query the database for that key to see if it exists, the reason I worry about this is because that means there will be a query every time a cell loads and thats alot of queries and network activity. I am unsure if that will be a problem.</p></li>
  </ol>
  
  <p>Thanks in advance! :)</p>