PrimaryKeyDescriptor describes a table primary key.

from message cosmos.orm.v1.PrimaryKeyDescriptor

Hierarchy

Constructors

Properties

autoIncrement: boolean = false

auto_increment specifies that the primary key is generated by an auto-incrementing integer. If this is set to true fields must only contain one field of that is of type uint64.

from field: bool auto_increment = 2;

fields: string = ""

fields is a comma-separated list of fields in the primary key. Spaces are not allowed. Supported field types, their encodings, and any applicable constraints are described below.

  • uint32 are encoded as 2,3,4 or 5 bytes using a compact encoding that is suitable for sorted iteration (not varint encoding). This type is well-suited for small integers.
  • uint64 are encoded as 2,4,6 or 9 bytes using a compact encoding that is suitable for sorted iteration (not varint encoding). This type is well-suited for small integers such as auto-incrementing sequences.
  • fixed32, fixed64 are encoded as big-endian fixed width bytes and support sorted iteration. These types are well-suited for encoding fixed with decimals as integers.
  • string's are encoded as raw bytes in terminal key segments and null-terminated in non-terminal segments. Null characters are thus forbidden in strings. string fields support sorted iteration.
  • bytes are encoded as raw bytes in terminal segments and length-prefixed with a 32-bit unsigned varint in non-terminal segments.
  • int32, sint32, int64, sint64, sfixed32, sfixed64 are encoded as fixed width bytes with an encoding that enables sorted iteration.
  • google.protobuf.Timestamp and google.protobuf.Duration are encoded as 12 bytes using an encoding that enables sorted iteration.
  • enum fields are encoded using varint encoding and do not support sorted iteration.
  • bool fields are encoded as a single byte 0 or 1.

All other fields types are unsupported in keys including repeated and oneof fields.

Primary keys are prefixed by the varint encoded table id and the byte 0x0 plus any additional prefix specified by the schema.

from field: string fields = 1;

fields: FieldList = ...
runtime: ProtoRuntime = proto3
typeName: "cosmos.orm.v1.PrimaryKeyDescriptor" = "cosmos.orm.v1.PrimaryKeyDescriptor"

Methods