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

Patch to support $or queries [moved] #104

Closed
jyemin opened this issue Apr 25, 2013 · 0 comments
Closed

Patch to support $or queries [moved] #104

jyemin opened this issue Apr 25, 2013 · 0 comments

Comments

@jyemin
Copy link
Contributor

jyemin commented Apr 25, 2013

This is Issue 104 moved from a Google Code project.
Added by 2010-09-01T19:32:32.000Z by normel...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Enhancement, Priority-Low, Milestone-Release0.97

Original description

I propose the following patch to support "$or" queries. There are a few ways it can be used, I'll attach examples below.

Admittedly, this was a pretty quick hack. I read the entire Query library sourcecode, but this seems to work. If nothing else, maybe it will serve as a model for someone else's implementation?

== USING AN OR-BUILDER

Query<Asset> query = ds.createQuery(AssetState.class);

OrBuilder<Asset> or = query.or();

or.add().field(&quot;name&quot;).equal(&quot;asset-1&quot;);
or.add().field(&quot;name&quot;).equal(&quot;asset-2&quot;);
or.add().field(&quot;name&quot;).equal(&quot;asset-3&quot;);

== ADDING A COLLECTION OF SUBQUERIES

Query<Asset> query = ds.createQuery(AssetState.class);

List<Query<Asset>> queries = new ArrayList<Query<Asset>>();

queries.add(ds.createQuery(AssetState.class).field(&quot;name&quot;).equal(&quot;asset-1&quot;));
queries.add(ds.createQuery(AssetState.class).field(&quot;name&quot;).equal(&quot;asset-2&quot;));
queries.add(ds.createQuery(AssetState.class).field(&quot;name&quot;).equal(&quot;asset-3&quot;));

query.or(queries)
@jyemin jyemin closed this as completed Apr 25, 2013
fwautobuild pushed a commit to fwHub/morphia that referenced this issue Feb 2, 2021
fwautobuild pushed a commit to fwHub/morphia that referenced this issue Feb 2, 2021
fwautobuild pushed a commit to fwHub/morphia that referenced this issue Feb 2, 2021
fwautobuild pushed a commit to fwHub/morphia that referenced this issue Feb 2, 2021
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

No branches or pull requests

1 participant