# rowid · Rell standard library · Chromia Docs (concept)

> 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

Source: https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/rowid/

TYPE

# rowid

```signature
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:

Rell

```
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:

Rell

```
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.
```

**See Also**

1. [`integer` - Rell Standard Library](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/integer/)
2. [`gtv` - Rell Standard Library](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/gtv/)

Since 0.9.0

## Methods

[rowid](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/rowid/rowid/)

[to\_integer](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/rowid/to_integer/)
:   Get the integer value of this ROWID.

[View this page on docs.chromia.com](https://docs.chromia.com/pages/rell-stdlib/-rell%20-system%20-library/%5Broot%5D/rowid/index.html)Generated API reference, mirrored from the live docs
