-1

I have a 100 plus Entities of kind Employee in datastore. The key for the entity is username who logs in to the application. I need to add new attribute to Employee entity with some default value. How do I update all the entities in one shot? I cannot login with each users account to update the entity with new attribute.

I prefer to use java to do that.

1 Answer 1

0

If what you want is a mass update, there is none in the datastore unfortunately.

I would suggest grabbing the full Employee table, and then iterating through your results, adding the default value to your new attribute, and then put the entity back. Something like (might need some adjustements, this is just off the top of my head):

Query q = new Query("Employee")
PreparedQuery pq = datastore.prepare(q);

for (Entity result : pq.asIterable()) {
    result.setProperty("newProperty","default Value");
    result.put();
}

And remember to update your model, adding the default value you want in it. If you don't, any new data you put in won't have that default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.