I wish the Google API documentation was a little more newbie-proof.
I've worked my way through Selecting all entities, Updating an entity, inserting, and deleting. Now I would like to start selecting specific entities by criteria. The API https://datastore.googleapis.com/v1/projects/project-id-5200707080506492774:runQuery is for this purpose, and if I provide the payload of "query: {}" I get all entities. I can also filter by Kind. But I cannot figure out how to filter by a property. I try to get an entity by name with this JSON stringified payload:
var payload =
{
"query": {
"kind": [
{
"name": "Test"
}
],
"filter": {
"propertyFilter": {
"property": {
"name": "id"
},
"op": "EQUAL",
"value": {
"stringValue": "5634472569470976"
}
}
}
}
}
But I get the 200 results batch:
{
"batch": {
"entityResultType": "FULL",
"endCursor": "CgA=",
"moreResults": "NO_MORE_RESULTS"
}
}
AKA: Nothing was found.
Could someone enlighten me with regards to how to select by the entity's name/id or other field of data?
EDIT:
Here is the file structure of my entities. They are organized under the kind Test:
{
"batch": {
"entityResultType": "FULL",
"entityResults": [
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5634472569470976"
}
]
},
"properties": {
"test": {
"stringValue": "Hi it is me"
}
}
},
"cursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1
MDY0OTI3NzRyEQsSBFRlc3QYgICAgN6QgQoMGAAgAA==",
"version": "1503343869436000"
},
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5639445604728832"
}
]
},
"properties": {
"test": {
"stringValue": "testtesttest"
}
}
},
"cursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgLyhggoMGAAgAA==",
"version": "1503343008992000"
},
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5649391675244544"
}
]
},
"properties": {
"test": {
"stringValue": "testtest"
}
}
},
"cursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgPjChAoMGAAgAA==",
"version": "1503342946693000"
},
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5659313586569216"
}
]
},
"properties": {
"test": {
"stringValue": "testtesttest"
}
}
},
"cursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgNrjhgoMGAAgAA==",
"version": "1503343059530000"
},
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5715999101812736"
}
]
},
"properties": {
"test": {
"stringValue": "hello world"
}
}
},
"cursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgLzVkwoMGAAgAA==",
"version": "1503343819165000"
}
],
"endCursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgLzVkwoMGAAgAA==",
"moreResults": "NO_MORE_RESULTS"
}
}
Edit:
I completed a filter query to check against my test field, as requested, and got the below 200 response:
{
"batch": {
"entityResultType": "FULL",
"entityResults": [
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707080506492774"
},
"path": [
{
"kind": "Test",
"id": "5715999101812736"
}
]
},
"properties": {
"test": {
"stringValue": "hello world"
}
}
},
"cursor":
"CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA
1MDY0OTI3NzRyEQsSBFRlc3QYgICAgLzVkwoMGAAgAA==",
"version": "1503343819165000"
}
],
"endCursor": "CjsSNWogc35wcm9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyEQsSBFRlc3QYgICAgLzVkwoMGAAgAA==",
"moreResults": "NO_MORE_RESULTS"
}
}
Testentity withid5634472569470976and no ancestor? - Dan Cornilescu