google-cloud-platformgoogle-cloud-datastoredatastoregqlgqlquery

Querying using custom key identifier(Name/ID) in firestore(datastore mode)?


I have a datastore entity like this below

     Name/ID              Parent                       Rollen             email          first_name      last_name
name=CidassUID  Key(Tenant, 'CidassGroupID')    ["user","admin"]    user@email.com  user first name user last name  

I would like to make a query w.r.t Name/ID

In GQL I am trying like this

 select * from User where Name/ID='CidassUID'

and in python like this..

    query = client.query(kind='User')
    query.add_filter('Name/ID', '=', 'name=CidassUID')
    return list(query.fetch())

Can somebody help how can I get the result via Name/ID?

Thanks a lot


Solution

  • so thats how i solve it in GQL..

    select * from User where __key__= Key(Tenant, 'CidassGroupID', User, 'CidassUID')
    

    and for python..

    query_key=client.key('Tenant', 'CidassGroupID','User', 'CidassUID')
    query.key_filter(query_key,'=')