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 filter on nested property value. #222

Open
jeffj6123 opened this issue Feb 24, 2020 · 5 comments
Open

query filter on nested property value. #222

jeffj6123 opened this issue Feb 24, 2020 · 5 comments

Comments

@jeffj6123
Copy link

jeffj6123 commented Feb 24, 2020

Is there a proper way to query on a nested property like this example below.

`
interface KeyValue {
key: string;
value: string;
}

interface KeyValueContainer {
container: KeyValue[];
}

// Pass it on Schema creation
const schema = new Schema({
container: { type: Array, optional: false },
});

const Kvc = gstore.model('KVC', schema);

Kvc.query().filter("container.key", "=", "test");
`
At the last line I get
Argument of type '"container.key"' is not assignable to parameter of type '"container"'.ts(2345)

it looks like the filter only accepts the top level properties.
Is there a way to handle this query in gstore-node or do I need to drop down to the base google cloud library?

Like I can drop <any> in front of the "container.key" string to remove the error but that feels like a weak solution.

@sebelga
Copy link
Owner

sebelga commented May 9, 2020

Hi @jeffj6123, sorry for the late answer!

Do you have an example on the Google doc (https://googleapis.dev/nodejs/datastore/latest/index.html) where it filters by an Array item and then property of the object? So I can understand better what you are trying to do.
Cheers! 👍

@jeffj6123
Copy link
Author

Hey,
@sebelga I am trying exactly where they mention it in their docs, but here is a reference to other people talking about it https://stackoverflow.com/questions/37290722/filter-entities-on-a-sub-entity-property-in-google-datastore-query . I have originally gotten familiar with it by using the python NDB where it allows for that.

@jeffj6123
Copy link
Author

Hey I wondered if there are any updates here?

@sebelga
Copy link
Owner

sebelga commented Dec 15, 2020

Hello, sorry for the late answer. I don't have the bandwidth to work currently on the project but there is a new maintainer who will be taking the lead shortly. I am going to label this issue as feature request and hopefully, we will be able to look into this.

In the short term, if by adding any you manage to make the query work, that's an acceptable solution 😊

@dmk1111
Copy link
Contributor

dmk1111 commented Nov 18, 2021

Hey, @jeffj6123
You can pass options with filter on nested properties:
Знімок екрана 2021-11-18 о 12 26 43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants