-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determining existence of relationship without server query #2271
Comments
Relevant: #2431 |
emberjs/rfcs#57 is aiming to address this |
I think this issue can be closed since an initial implementation of references has been merged into |
Closing in favor of references! |
#7796 will add autotracking for this feature |
awesome @runspired |
Sometimes it's useful to determine if a relationship is present without querying the server.
child.get('mother')
will query the server if the mother isn't present.This private API returns the answer without querying the server
!!child._relationships.mother.inverseRecord
.On knowledge of associated records
Mostly, only the 1-side in N-1 and 1-1 relationships will know whether it's associated with another record (given how foreign keys are located). The N-side won't know without querying the server.
Ways to provide this
child.isPresent('mother')
return true/falsechild.get('mother', { local: true })
return the record if it exists in store, otherwise nullchild.count('mother')
could return without querying the server for 1-side, and could trigger a server request for the N-side. It's main usage would obviously be remote counting, but that way the API addition would be useful for more than probing for existence.eachRelationship
could be amended to provide info on relationship presence (similar to the current, private, API quoted above).I think I like (3) the most, but depends on whether others think that's a useful addition. Thoughts?
The text was updated successfully, but these errors were encountered: