Skip to content
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

Add 'include' option to memorySource.find and memorySource.findLinked #123

Closed
wants to merge 2 commits into from

Conversation

opsb
Copy link
Contributor

@opsb opsb commented Mar 30, 2015

Just opening this to allow discussion.

Adds the following option to find:

source.find('planet', 'planet1', {include: ["moons", "sun"]});

@opsb
Copy link
Contributor Author

opsb commented Mar 30, 2015

I'm wondering if we should be adding the 'include' option to findLinked. I notice that findLinked isn't listed in the methods for requestable in the orbit.js readme so I'm not sure if it's considered part of the public API or not(possibly the readme just hasn't been updated). If it is I think it would be more consistent to allow the 'include' option with findLinked. What's the general feeling?

@opsb
Copy link
Contributor Author

opsb commented Mar 30, 2015

Another issue, wondering about the various ways to call find when options are included, you've got:

find('type')
find('type', options) << collision
find('type', id)
find('type', id, options)
find('type', ids)
find('type', ids, options)
find('type', queryObject) << collision
find('type', queryObject, options)

It's difficult to distinguish between the queryObject and options (they're all objects). The simplest option from an implementation point of view is that options always has to be passed as the 3rd argument. That's pretty ugly though for find('type', null, options).

@dgeb
Copy link
Member

dgeb commented Apr 3, 2015

The simplest option from an implementation point of view is that options always has to be passed as the 3rd argument. That's pretty ugly though for find('type', null, options).

One more argument for #110, in which options would always be the second argument.

For now though, I think options has to be the third argument.

@dgeb
Copy link
Member

dgeb commented Apr 3, 2015

I'm wondering if we should be adding the 'include' option to findLinked.

Yes, definitely.

I'm not sure if it's considered part of the public API or not(possibly the readme just hasn't been updated).

Sorry - the readme does need updating.

@opsb
Copy link
Contributor Author

opsb commented Apr 3, 2015

One more argument for #110

Yup, that does make sense, so we'd have:

find('type')
find('type', options)
find(id)
find(id, options)
find(ids)
find(ids, options)
find(queryObject)
find(queryObject, options)

@opsb
Copy link
Contributor Author

opsb commented Apr 3, 2015

Actually, seeing as type and id are both strings, how would we distinguish between the two?

@dgeb
Copy link
Member

dgeb commented Apr 3, 2015

Actually, seeing as type and id are both strings, how would we distinguish between the two?

find(id) // string
find(ids) // array
find({type: 'type'}) //object

@opsb
Copy link
Contributor Author

opsb commented Apr 3, 2015

Ha, that does seem pretty reasonable.

@opsb
Copy link
Contributor Author

opsb commented Apr 16, 2015

@dgeb This PR now adds support for the include option to both memorySource.find and memorySource.findLinked.

I've replaced the source.findLinked implementation, it seems to cover all the existing functionality, at least the tests pass anyway.

The options parsing is currently done in memory-source, in orbit-firebase I introduced an Options object which took care of this. It's a bit heavier though so perhaps you're happy with the way it is? (see https://github.com/orbitjs/orbit.js/pull/123/files#diff-3afbad5d9865c146aff683c3f945b68fR111)

@opsb opsb changed the title wip - adding 'include' option to source.find Add 'include' option to memorySource.find and memorySource.findLinked Apr 16, 2015
@opsb
Copy link
Contributor Author

opsb commented Apr 16, 2015

Another thought, I'd expect findLinked to return an empty array rather than null.

@opsb opsb mentioned this pull request Apr 24, 2015
@opsb opsb mentioned this pull request May 5, 2015
@dgeb
Copy link
Member

dgeb commented May 6, 2015

Merged via a3ca9aa and 55f111e

Wanted to get this in before beginning the major rebase refactor discussed in #110.

@dgeb dgeb closed this May 6, 2015
@opsb
Copy link
Contributor Author

opsb commented May 7, 2015

Thanks @dgeb! We' be been running an internal beta against orbit.ja and orbit-firebase for a couple of weeks now without bugs. Looking forward to the refactor in #110 as we've already get a case where we need polymorphism.

@dgeb
Copy link
Member

dgeb commented May 7, 2015

That's great news, @opsb!

@opsb opsb deleted the includes branch September 26, 2015 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants