SpacetimeDB
SpacetimeDB copied to clipboard
Trait for auto-inc sentinel values
Currently we use 0 all over the place in the codebase, implicitly because it is the sentinel value that means "replace me when I am inserted in to a table with a sequence defined on my column". We should make a trait for this. I would propose something like:
trait AutoIncrementable {
/// A constant that will be replaced with a unique value upon insertion into a column with the `auto_inc` attribute.
const SENTINEL: Self;
}
or something like that in spacetimedb_lib. This can be used in the client SDK, module SDK, and in the core database for e.g. SystemIDs.
Note that "auto-inc" and "sequence" are used as synonyms throughout the codebase. We should probably also settle on one of these for consistency of documentation...