Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Entities with string IDs #74

Open
tornewuff opened this issue Jun 6, 2013 · 3 comments
Open

Entities with string IDs #74

tornewuff opened this issue Jun 6, 2013 · 3 comments

Comments

@tornewuff
Copy link

A number of my model types have string IDs. Is there a way to use these as the value of the "id" property?

@dhermes
Copy link
Contributor

dhermes commented Jun 6, 2013

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.

@tornewuff
Copy link
Author

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)"

@dhermes
Copy link
Contributor

dhermes commented Jun 6, 2013

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants