rowid

type rowid

The primary key of a database record.

Implemented as a 64-bit integer, but requires explicit conversion to and from integer with the constructor rowid(integer) and the method rowid.to_integer(). ROWID values cannot be negative.

ROWID supports the standard complement of comparison operators (==, !=, <, >, <= and >=), and conversion to and from GTV.

Examples:

function get_rowid(username: text) {
val u = user @ { .name == username };
return u.rowid;
}

val freds_rowid: rowid = user @ { .name == "Fred" } ( .rowid );

val valid_rowids: list<rowid> = user @* { .rowid >= min_rowid };

Note that the recommended way to manipulate entity values is via typed references (e.g. u: user in the above example), as this is type-safe. Reliance on rowid is only recommended in rare cases where the standard pattern is not possible, as the compiler does not know what type of entity a given rowid value is intended to reference. Consider the example below:

entity user {}
entity company {}

val u: user = user @ {};
val c: company = company @ {};

val u2: user = c; // Bad, and the compiler tells us so.

val u_rowid: rowid = c.rowid; // Likely to lead to errors, but the compiler can't help us.

Since

0.9.0

See also

Constructors

Link copied to clipboard
pure constructor(value: integer)

Construct a ROWID from an integer value.

Functions

Link copied to clipboard
pure function to_integer(): integer

Get the integer value of this ROWID.