2017-04-03 26 views
0

我已經查詢到獲取所有Event Data實體的列表。結果是谷歌數據存儲這樣來了。如何查詢Google Cloud Datastore中的數組

[{ 
    "key": { 
    "id": 5678669024460800, 
    "kind": "Event", 
    "path": [ 
     "Event", 
     5678669024460800 
    ] 
    }, 
    "data": { 
    "createdAt": "2017-03-27T06:28:58.000Z", 
    "users":["[email protected]","[email protected]","[email protected]"] 
    } 
}, 
{ 
    "key": { 
    "id": 5678669024460800, 
    "kind": "Event", 
    "path": [ 
     "Event", 
     5678669024460800 
    ] 
    }, 
    "data": { 
    "createdAt": "2017-03-27T06:28:58.000Z", 
    "users":["[email protected]"] 
    } 
}, 
{ 
    "key": { 
    "id": 5678669024460800, 
    "kind": "Event", 
    "path": [ 
     "Event", 
     5678669024460800 
    ] 
    }, 
    "data": { 
    "createdAt": "2017-03-27T06:28:58.000Z", 
    "users":["[email protected]","[email protected]"] 
    } 
}] 

但我需要寫一個查詢過濾Email'id。意味着我需要獲取與電子郵件ID匹配的實體。例如,如果我通過電子郵件作爲[email protected]我應該得到這樣的最終結果。任何人都可以幫助我解決這個問題。

[{ 
    "key": { 
    "id": 5678669024460800, 
    "kind": "Event", 
    "path": [ 
     "Event", 
     5678669024460800 
    ] 
    }, 
    "data": { 
    "createdAt": "2017-03-27T06:28:58.000Z", 
    "users":["[email protected]","[email protected]","[email protected]"] 
    } 
}, 
{ 
    "key": { 
    "id": 5678669024460800, 
    "kind": "Event", 
    "path": [ 
     "Event", 
     5678669024460800 
    ] 
    }, 
    "data": { 
    "createdAt": "2017-03-27T06:28:58.000Z", 
    "users":["[email protected]"] 
    } 
}] 

回答

2

的GQL查詢會是這樣的 -

SELECT * FROM Event WHERE users='[email protected]' 

你需要確保users財產是爲了索引的搜索工作,否則你可能不會得到任何結果回來。

相關問題