3

I have this data model:

Album <--->> Photo <--->> Like <<---> User

I want to get the photos from specific Album and I want to attach Likes to them as well. I would like to have some equivalent of a Fetched Property, because I don't want to get an array of likes to each photo, I just want to have the one like.

Here's related Backendless support question: http://support.backendless.com/topic/join-equivalent-for-find-fetched-properties

Miroslav Kuťák
  • 1,755
  • 1
  • 15
  • 24
  • Do you mean you want each photo and its number of likes for a given album? – philipxy Mar 05 '16 at 23:29
  • Yes, but that's not my question. My question is how to get one particular "Like" entity, that determines relationship between the current user and the photo. I want to know if I like the photo or not. – Miroslav Kuťák Mar 07 '16 at 08:55
  • You are not clear. (In your question, your comment, or your linked posts.) Please explain what you want and give example input & output, including parameters and table definitions & contents. – philipxy Mar 10 '16 at 02:42

2 Answers2

1

You can apply complex NSPredicate to the fetch request, it can analyse both the direct attributes of the target entity of a fetch and the attributes of its relationships

Try :

NSPredicate(format: "(albums = %@) AND (SUBQUERY(likes, $l, $l IN %@).@count > 0)", album, user.likes)
deoKasuhal
  • 2,627
  • 17
  • 26
-1

you should use core data as it is using ORM it will satisfy all your needs

techloverr
  • 2,501
  • 1
  • 14
  • 28