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

Nested property where clause with Sails.js 1.0 not working anymore #4133

Closed
ndabAP opened this issue Jun 25, 2017 · 4 comments
Closed

Nested property where clause with Sails.js 1.0 not working anymore #4133

ndabAP opened this issue Jun 25, 2017 · 4 comments

Comments

@ndabAP
Copy link

ndabAP commented Jun 25, 2017

Sails version: 1.0.0-36
Node version: 7.9.0
NPM version: 4.2.0
Operating system: Ubuntu
Data base: MongoDB


I use a decorator pattern to react to user input. The user can filter data by range or bigger/smaller as. The properties are nested. After upgrading to Sails.js 1.0 this stopped working. It looks something like this:

let dataset = Data
  .find({
    table: table.id
})

// ...

if (startValue && endValue) {
  dataset
    .where({
        [`data.${columnLabel}`]: {
          '<': endValue,
          '>': startValue
        }
  })
}

// ...

This results in error:

Could not use the provided where clause. Could not filter by data.property: data.property is not a valid name for an attribute in Waterline. Even though this model (data) declares schema: false, this is not allowed.

@sailsbot
Copy link

@ndabAP 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.

@sgress454
Copy link
Member

Hi @ndabAP -- it looks like you were relying on some undocumented features of Waterline that just happened to work in previous versions; namely using native Mongo query syntax within a Waterline query. In 1.0, you'll need to use the lower-level datastore functionality.

@ndabAP
Copy link
Author

ndabAP commented Jun 29, 2017

@sgress454, thank you for the clarification.

I ended up using your solution plus mquery which supports dot notation (e. g. nested.property).

@sean-clayton
Copy link

sean-clayton commented Sep 14, 2017

@sgress454 Is it possible to do this with Waterline on the client? I understand with .manager you can make it work on the server side, but we would like to be able to do a query like find({'nested.object': 'value'}) on the client.

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

4 participants