简体   繁体   中英

how to query a complex property in google cloud datastore

I have an entity created in Datastore with a complex property (or document? I don't know exactly what to call it! Please tell me the correct name for it) which looks like this:

taskId: "T101",
taskType: "Pick",    
itemInfo:
{
 "id":"00014",
 "actualQty":"1",
 "attributes":[{"value":"Large","name":"Size"},"value":"Blue","name":"Color"}],
 "requiredQty":"10",
 "imageUrl":" ",
 "upc":"886654801"
} 

I want to query on the upc field in the itemInfo property. (Please don't ask me to move upc out of itemInfo property!). I know that for querying anything we need to have index defined and I have taskId in my index.yaml.

something like:

select * from Task where itemInfo.upc = "<some value>";

Please tell me we can do it somehow!

Thanks.

Assuming the entity Kind is Task in the Datastore, and that it has taskId , taskType and itemInfo properties, with itemInfo being embedded entity, the query you mentioned should work fine.

SELECT * FROM Task WHERE itemInfo.upc='886654801'

Just keep in mind that property names and values are case sensitive. Also, itemInfo property should be indexed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM