When i construct the sst.Table instance. is there ...
# help
e
When i construct the sst.Table instance. is there a way to mark a property as auto-increment? or no such animal in this case?
t
Auto incrementing is generally not a thing in distributed databases. There is a really sophisticated way of creating an auto increment scheme in dynamo but not recommended
e
ah, im trying to build a chat group table and sort the messages based on order. unless when i call dynamoDB.put() it inserts the item at the bottom?
r
You can use a ksuid or ulid as the ID which are unique but date sortable. If you use the SenseDeep OneTable library it has this built-in
e
then again, i could just add a datetime property and use that as a sort key.
d
Can you do transactWrite and then just do an pk / sk of the chat id and increment messages. Then use the SK as a gsi on sort order?
e
@Devin imma write that one down 🙂
r
@Ernie Francis the trouble with a datetime as a sort key is that, if you ever needed to uniquely identify a record by PK and SK, it's difficult to do so
e
@Ross Gerbasi i do use UUIDv4 to generate unique PK's, even with that i would run into issues?
r
Assume you meant me. Not issues, but UUIDs aren't datetime sortable whereas ULIDs and KSUIDs are
t
Second the recommendation for ulid or ksuid, it's definitely what you want for a situation like this
r
Ah another summoning of the wrong Ross haha. However I also recommend ulid, haven't looked back.
t
we're going to need one of you to change your name thanks
r
Or merge...
r
OK, fair enough, let me get my deed poll docs done this week
Curious what a merge would be like, I've never looked as good in hats as Ross Gerbasi