-
Notifications
You must be signed in to change notification settings - Fork 108
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
FR: Querying a subset of an embedded entity properties. #766
Comments
Sorry, I don't quite follow. It seems you are wondering if we should make a, likely breaking, change, to the way results are returned? |
I think the current API is inconsistent: const [entities] = await datastore.createQuery('TEST').run();
// returns
[{
emb: {
name": 'first',
value: 1,
},
},]
vs
const [entities] = await datastore.createQuery('TEST').select('emb.name').run();
// returns
[{
"emb.name": 'first',
},] That is the shape of the result depends on whether you have or not a I can imagine multiple solutions for it not to be a breaking change.
const [entities] = await datastore.createQuery('TEST').select('emb.name').run();
// *would* return
[{
"emb.name": 'first',
emb: {name: "first"},
},] |
Okay, I think I understand. Going to restate to be sure though :) Select, when selecting the mentioned field, returns the key as the select statement. In this case "emb.name". You would prefer if the returned object was still nested as it is in the full object, even though it is a single field. And you are proposing that we could return it in both forms in the dict to allow users to use the existing way, as well as an additional way that would match the structure of the object without a select query. |
Yep that is what I meant.
You can select multiple fields too in which case there will be |
I think this is a reasonable request. I did a quick compare with how this works in Python
It seems we keep it consistent there which points to there being a precedence for this. I think if we can do this in a non-breaking way I could be okay with this. @bcoe can you weigh in from a more seasoned node perspective? |
Let's say you save this entity:
You can they run a query to retrieve that entity:
That is expected.
Now if you select only some properties, the output format would be different:
I have not found any documentation about querying embedded entities so I am not sure if this is expected ?
Do you think it would be worth expanding the response to a partial object in the second case, ie
This would make the client code consistent whether or not the query selects only a subset of the embedded property.
Note: this would have to be done on the client side.
When there is no select clause, the server returns:
but when there is select, the server would return
The text was updated successfully, but these errors were encountered: