Class E003_UniqueKeys
Unique business keys (V4 [RedbUnique]): the value of a marked field is unique within
its scheme, enforced by the DATABASE over the hash of the canonical value - not by a
pre-check that races. The contract shown here:
A duplicate save fails with a typed .
GetByUniqueAsync finds an object by its key value (server-side, hash lookup).
NULL never participates: any number of objects may leave the key empty.
Soft delete releases the key - the trash does not squat on business identifiers.
redb carries TWO unique-key mechanisms, both shown here:
[RedbUnique] on a Props field - per-FIELD uniqueness, any scalar type, hash in
_values._unique;
RedbObject.value_unique - a per-OBJECT string key on the object row itself
(scheme-wide, up to 440 chars, no Props field needed) - the natural slot for an external
identifier of the whole object.
[ExampleMeta("E003", "Unique Keys - [RedbUnique] and value_unique", "CRUD", ExampleTier.Free, 3, new string[] { "Unique", "RedbUnique", "ValueUnique", "GetByUniqueAsync", "SoftDelete" }, RelatedApis = new string[] { "IRedbService.GetByUniqueAsync", "IRedbService.SaveAsync" })]
public class E003_UniqueKeys : ExampleBase
Inheritance
Inherited Members
Methods
RunAsync(IRedbService)
Run the example and return result.
public override Task<ExampleResult> RunAsync(IRedbService redb)