user2924127
user2924127

Reputation: 6252

gcloud nodejs library see if entity exists efficently

I am using glcoud nodejs library for Google datastore (https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.26.0/datastore). I am registering users and as a check I want to only insert if the username (key) is not already registered. I want to only see if the entity already exists, but I don't want to use the get command because it will retrieve the entire entity (the entities are about 400KB in size each). As a result I would only like the most minimal information to return to just acknowledge this entity already exists. I looked into the query option to somehow select only keys, but this does not seem possible? One option is to create an index on just one other field and use projection queries to retrieve only that field and if it returns the object exists. The problem with his though is I have to create an index, which automatically increase my write costs and since this entity will be modified quite often I don't really want to create an index which has no purpose other than to be able to use projection queries on. Is there a solution to this?

Upvotes: 0

Views: 270

Answers (0)

Related Questions