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

Error using $exists modifier #4609

Open
macpatel opened this issue Jan 16, 2019 · 4 comments
Open

Error using $exists modifier #4609

macpatel opened this issue Jan 16, 2019 · 4 comments
Labels
does this answer your question? orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.

Comments

@macpatel
Copy link

Waterline version: 0.13.5-0
Node version: 8.12.0
NPM version: 6.4.1
Operating system: Ubuntu 16.04


I want to query using complex condition like using exists, neq operators. But this gives error saying "exists" operator is invalid modifier. In v 0.12 it used to work.

  let users = await global.dbModels.user
    .find({
      $and:[
        {
          $or: [
            // { isNewUserHijackerJobErrored: true },
            // { isNewUserHijackerJobErrored : { $exists : false } }
            { isNewUserHijackerJobInProgress: false },
            { isNewUserHijackerJobInProgress : { $exists : false } }
          ]
        },
        {
          $or: [
            { newUserHijackerJobStepName : { $neq: konstant.STEP_NAME_FINISHED } },
            { newUserHijackerJobStepName : { $exists : false } }
          ]
        }
      ]
    });
@sailsbot
Copy link

@macpatel Thanks for posting, we'll take a look as soon as possible.


For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.

@macpatel
Copy link
Author

i found this issue linked with this -> https://github.com/balderdashy/waterline/issues/1553

@rachaelshaw
Copy link
Member

@macpatel in case it helps: when I'm trying to only look up records that have a value set for a specific attribute, I usually just check that its not equal to that attribute's base value (or default value if it was configured with defaultsTo).

e.g.:

await User.find({
  age: { '!=': 0 },
  and: [
    { favoriteColor: { '!=' : '' } },
    { favoriteColor: { '!=' : 'aubergine' } },
  ]
});

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline Mar 6, 2019
@balderdashy balderdashy deleted a comment from sailsbot Mar 6, 2019
@johnabrams7 johnabrams7 added the orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. label Mar 6, 2019
@johnabrams7
Copy link
Contributor

Hey @macpatel, we're currently moving all the Waterline cases to the main Sails repo (balderdashy/sails). I see the last update was a response to the original issue - feel free to update us if this remains ongoing. Thanks for the efforts so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
does this answer your question? orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.
Development

No branches or pull requests

4 participants