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

Fails for {$ne: null} #1

Open
ben-pr-p opened this issue Oct 23, 2016 · 3 comments
Open

Fails for {$ne: null} #1

ben-pr-p opened this issue Oct 23, 2016 · 3 comments
Labels

Comments

@ben-pr-p
Copy link

ben-pr-p commented Oct 23, 2016

Love the library idea. Boundary case!

Doesn't handle {$ne: null} properly.

const data = [{prop: null}, {prop: 'hi'}]
const f = new Faltu(data)
console.log(f.find({prop: {$ne: null}}).get().length)
// logs 0

I believe it's this line, not sure:
https://github.com/moinism/faltu/blob/master/src/faltu.js#L101

Is there another recommended way to check for a property not equaling null?

@ben-pr-p
Copy link
Author

It also doesn't work for {$eq: null}.

Support for the $and operator would be a workaround (and a nice feature) - then a query of

{$and: [
  {$lt: ''},
  {$gt: ''}
]}

would work.

Depending on my availability I may be able to do this

@ben-pr-p
Copy link
Author

I was able to get {prop: {$eq: null}} to work by doing {prop: [null]}, so I'm happy.

Not sure if this is a use-case you're interested in supporting.

@moinism
Copy link
Owner

moinism commented Oct 24, 2016

Glad to see that you've found a way. One workaround for the {$ne: null} problem would be to use filter.

Like:

console.log(f.find().filter(function (item) {
  return item.prop != null;
}).get().length)

You can do the same with $eq too. I'll try to fix these though.

Also, we'd love it if you could add the $and operator.

@moinism moinism added the bug label Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants