Open tornewuff opened 11 years ago
Short answer: yes, there is a way.
Thanks for the question @tornewuff. Would you mind asking this as a question on StackOverflow and I'll be happy to answer there?
If not, you should check out the Custom Alias Properties example in the documentation. If that clears it up, no need for the StackOverflow question. If not, I'm happy to answer there.
Ah, I didn't read that example yet, oops. Would it be worth having the alternate getter/setter implemented in the library somehow, to save having to add it to each class? Something like "_message_id_string = True" seems nice and self-documenting, though I guess it's still only one line to reuse the same functions in all entity classes: "id = property(StringIdGet, StringIdSet)"
Yep, issue #21 has asked for this and I think your suggestion perfectly crystallizes this :)
Thanks for the insight.
I don't like _message_id_string = True
approach because less is more when we're talking about expanding the interface of what people have to deal with. But added more utility methods (e.g. StringIdGet
and StringIdSet
) is totally do-able.
I should probably add that to https://github.com/GoogleCloudPlatform/endpoints-proto-datastore/wiki/APIDesignWisdom
A number of my model types have string IDs. Is there a way to use these as the value of the "id" property?