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

Query Records by empty or non-empty values #6275

Closed
esopian opened this issue Dec 3, 2013 · 14 comments
Closed

Query Records by empty or non-empty values #6275

esopian opened this issue Dec 3, 2013 · 14 comments

Comments

@esopian
Copy link

esopian commented Dec 3, 2013

Need a way to get a list of records based on whether they have a property assigned or not and not based on the actual value of the property. Tried to query with null, empty string, undefined, and false using the MongoDB adapter with no success.

Example use case: I have a collection of Invoices with a property of "paidDate". I want to get all Invoices with no paidDate set (unpaid invoices).

@Samstiles
Copy link

+1 -- esopian and I dabbled with a number of different ways of querying in order to make this work and none did... unless we're both dumb and missed something.

Er go,

Querying for records with a specific value.... .where({ age: 21 })

-- VS --

Querying for records which DO or DON'T even have that value in their object schema at all... .where({ age }) || .where({ !age }) || .where({ exists: age }) || .where({ age: undefined }) -- or something along those lines. None of the above work (we thought the last one should)

@tbarho
Copy link

tbarho commented Jan 15, 2014

+1

@CWyrtzen
Copy link

CWyrtzen commented Jun 5, 2014

This has been logged as a FR and will be pushed to Trello in the near future. Thanks for the input!

Update 07_23: we will not be using Trello but have devised a system for users to submit Feature Requests outside of issues. It will be announced as soon as we get the system in place on our end.

@artworkad
Copy link
Contributor

+1

@dmarcelino
Copy link
Member

I'd like to resurrect this issue if nobody objects. This seems to be very useful functionality and several people have shown interest both in this thread and in stackoverflow #27682106 / #22772742.

@dmarcelino
Copy link
Member

My proposal is to use a criteria modifier, empty, so one could query for empty like:

  • model.find( field: { empty: true } )

We also need to consider how this would behave in schemaless DBs where the field may not exist at all. If we want to be more specific we could add another criteria modifier to cover the case where the field doesn't exist at all such as exists:

  • model.find( field: { exists: false } )

Any opinions about this?

@balnagy
Copy link

balnagy commented Sep 4, 2015

+1. Any workaround?

@sailsbot
Copy link

sailsbot commented Oct 5, 2015

Thanks for posting, @esopian. I'm a repo bot-- nice to meet you!

It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:

  • review our contribution guide to make sure this submission meets our criteria (only verified bugs with documented features, please; no questions, commentary, or bug reports about undocumented features or unofficial plugins)
  • create a new issue with the latest information, including updated version details with error messages, failing tests, and a link back to the original issue. This allows GitHub to automatically create a back-reference for future visitors arriving from search engines.

Thanks so much for your help!

@devinivy
Copy link

devinivy commented Oct 5, 2015

Reopening until someone submits a PR to the roadmap for this feature.

@CarlosVitorino
Copy link

+1

@sailsbot
Copy link

sailsbot commented Dec 3, 2015

Thanks for posting, @esopian. I'm a repo bot-- nice to meet you!

It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:

  • review our contribution guide to make sure this submission meets our criteria (only verified bugs with documented features, please; no questions, commentary, or bug reports about undocumented features or unofficial plugins)
  • create a new issue with the latest information, including updated version details with error messages, failing tests, and a link back to the original issue. This allows GitHub to automatically create a back-reference for future visitors arriving from search engines.

Thanks so much for your help!

@particlebanana
Copy link
Contributor

Reopening until someone submits a PR to the roadmap for this feature.

@randallmeeker
Copy link

Reopening until someone submits a PR to the road map for this feature.

It's on the road map.

@sohail0992
Copy link

Is this functionality implemented or still on the road map

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline May 20, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests