# bookclerk_library::entities::portal_sessions

SeaORM entity for the `portal_sessions` table.

| Item | Kind | Summary |
| --- | --- | --- |
| [`Model`](#model) | struct | Row shape for this table (`DeriveEntityModel`). |
| [`ColumnIter`](#columniter) | struct | An iterator over the variants of [Column] |
| [`Entity`](#entity) | struct | Generated by sea-orm-macros |
| [`PrimaryKeyIter`](#primarykeyiter) | struct | An iterator over the variants of [PrimaryKey] |
| [`ActiveModel`](#activemodel) | struct | Generated by sea-orm-macros |
| [`RelationIter`](#relationiter) | struct | An iterator over the variants of [Relation] |
| [`Column`](#column) | enum | Generated by sea-orm-macros |
| [`PrimaryKey`](#primarykey) | enum | Generated by sea-orm-macros |
| [`Relation`](#relation) | enum | Declared SeaORM relations (none unless FK edges are modeled). |

## Structs

### Model

```rust
pub struct Model {
    pub id: i64,
    pub token_hash: String,
    pub identity_id: i64,
    pub expires_at: String,
    pub created_at: String,
    pub last_used_at: Option<String>,
    pub user_agent: Option<String>,
    pub device_type: Option<String>,
    pub client_label: Option<String>,
    pub kind: String,
}
```

Row shape for this table (`DeriveEntityModel`).

**Fields**

- `id`: Surrogate primary key assigned by the database.
- `token_hash`: SHA-256 hex digest of the opaque token (plaintext never stored).
- `identity_id`: Foreign key to `portal_identities.id`.
- `expires_at`: RFC 3339 expiry for the ticket, session, or code.
- `created_at`: RFC 3339 timestamp when the row was inserted.
- `last_used_at`: RFC 3339 time of the last authenticated use of this session.
- `user_agent`: Raw User-Agent captured at session mint (optional).
- `device_type`: Best-effort device class (`desktop` / `mobile` / `tablet` / `api`).
- `client_label`: Best-effort OS / client label (`Windows`, `Android`, `API`, …).
- `kind`: Where the token is presented: `browser` (the session cookie) or
  `clerk` (a library card, sent as `Authorization: Bookclerk-Clerk`
  header); see [`crate::models::PortalSessionKind`](/docs/internals/crates/bookclerk_library/index.md#portalsessionkind).

#### Model::into_ex

```rust
pub fn into_ex(self) -> Self
```

Generated by sea-orm-macros

Implements: `Clone`, `Debug`, `Eq`, `From<Model>`, `FromQueryResult`, `IntoActiveModel<ActiveModel>`, `ModelTrait`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### ColumnIter

```rust
pub struct ColumnIter {
    /* private fields */
}
```

An iterator over the variants of [Column](#column)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### Entity

```rust
pub struct Entity;
```

Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Default`, `EntityName`, `EntityTrait`, `Iden`, `IdenStatic`

### PrimaryKeyIter

```rust
pub struct PrimaryKeyIter {
    /* private fields */
}
```

An iterator over the variants of [PrimaryKey](#primarykey)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### ActiveModel

```rust
pub struct ActiveModel {
    pub id: ActiveValue<i64>,
    pub token_hash: ActiveValue<String>,
    pub identity_id: ActiveValue<i64>,
    pub expires_at: ActiveValue<String>,
    pub created_at: ActiveValue<String>,
    pub last_used_at: ActiveValue<Option<String>>,
    pub user_agent: ActiveValue<Option<String>>,
    pub device_type: ActiveValue<Option<String>>,
    pub client_label: ActiveValue<Option<String>>,
    pub kind: ActiveValue<String>,
}
```

Generated by sea-orm-macros

**Fields**

- `id`: Generated by sea-orm-macros
- `token_hash`: Generated by sea-orm-macros
- `identity_id`: Generated by sea-orm-macros
- `expires_at`: Generated by sea-orm-macros
- `created_at`: Generated by sea-orm-macros
- `last_used_at`: Generated by sea-orm-macros
- `user_agent`: Generated by sea-orm-macros
- `device_type`: Generated by sea-orm-macros
- `client_label`: Generated by sea-orm-macros
- `kind`: Generated by sea-orm-macros

Implements: `ActiveModelBehavior`, `ActiveModelTrait`, `Clone`, `Debug`, `Default`, `From<Model>`, `IntoActiveModel<ActiveModel>`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### RelationIter

```rust
pub struct RelationIter {
    /* private fields */
}
```

An iterator over the variants of [Relation](#relation)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

## Enums

### Column

```rust
pub enum Column {
    Id,
    TokenHash,
    IdentityId,
    ExpiresAt,
    CreatedAt,
    LastUsedAt,
    UserAgent,
    DeviceType,
    ClientLabel,
    Kind,
}
```

Generated by sea-orm-macros

**Variants**

- `Id`: Generated by sea-orm-macros
- `TokenHash`: Generated by sea-orm-macros
- `IdentityId`: Generated by sea-orm-macros
- `ExpiresAt`: Generated by sea-orm-macros
- `CreatedAt`: Generated by sea-orm-macros
- `LastUsedAt`: Generated by sea-orm-macros
- `UserAgent`: Generated by sea-orm-macros
- `DeviceType`: Generated by sea-orm-macros
- `ClientLabel`: Generated by sea-orm-macros
- `Kind`: Generated by sea-orm-macros

Implements: `Clone`, `ColumnTrait`, `Copy`, `Debug`, `FromStr`, `Iden`, `IdenStatic`, `IntoEnumIterator`

### PrimaryKey

```rust
pub enum PrimaryKey {
    Id,
}
```

Generated by sea-orm-macros

**Variants**

- `Id`: Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Iden`, `IdenStatic`, `IntoEnumIterator`, `PrimaryKeyToColumn`, `PrimaryKeyTrait`

### Relation

```rust
pub enum Relation {}
```

Declared SeaORM relations (none unless FK edges are modeled).

Implements: `Clone`, `Copy`, `Debug`, `IntoEnumIterator`, `RelationTrait`
