Open leggetter opened 1 year ago
@garrensmith @himank this could be done as an extension of secondary indexes.
@leggetter what you can do to get this behavior is what I have done here: https://github.com/tigrisdata/tigris-examples-ts/blob/main/rest-express/src/api/routes/signup.ts
@garrensmith @himank this could be done as an extension of secondary indexes.
That's the plan and it would be an easy extension for us.
@leggetter what you can do to get this behavior is what I have done here: https://github.com/tigrisdata/tigris-examples-ts/blob/main/rest-express/src/api/routes/signup.ts
Yes, specifically this https://github.com/tigrisdata/tigris-examples-ts/blob/main/rest-express/src/api/routes/signup.ts#L47-L58
The email, in this case, has to be unique.
In my case, I want the username to be unique.
@leggetter you should be able to replace the email with email
with username
and make username
the primary key and it will work the same
@leggetter you should be able to replace the email with
username
and makeusername
the primary key and it will work the same
@garrensmith - Gotcha. I know I can:
However, I'm suggesting a scenario where the developer wants to keep a separate ID as the primary key because the username could change but would like one field (the ID) to be consistent. My suggestion with this ticket is that Tigris supports a unique constraint on non-primary key fields.
Examples:
All of these places and types of apps and more, I believe, will have a unique ID that doesn't change along with a username that is also globally unique on the platform, but you can change it. Having the database manage this globally unique constraint seems to be a common requirement.
I agree that we need support for the field's uniqueness. These suggestions are just a workaround until we have that feature available.
Is your feature request related to a problem? Please describe.
Given the following:
I would like to be able to force the
username
field also to be unique.Although
username
can be changed, it should still be globally unique within the application that I'm building. I believe this is also a reasonable requirement in applications where a user has a human-readable, globally unique identifier.This is potentially similar to something like UNIQUE in MySQL.
Describe the solution you'd like
Something like:
See
@Field(TigrisDataTypes.STRING, { unique: true })
.Describe alternatives you've considered
Open to alternatives, but I couldn't think of any. Happy to discuss.