Skip to content

Query one non-optionalΒ #2974

@sinder38

Description

@sinder38

Motivation

I frequently query one row of something using .one(db) method and return an error if its None.

It would be nice to have a distinction between fetching one row and fetching optional row since its quite common(like in sqlx).

Proposed Solutions

I propose to add another method to various query implementations, to query non-optional and return

sea-orm/src/error.rs

Lines 51 to 53 in 4f89d1b

/// The record was not found in the database
#[error("RecordNotFound Error: {0}")]
RecordNotFound(String),

this error on None.

Additional Information

I think this feature would be relevant after error refactor proposed in one of the recent issues.
Naming this method seems a big problem as .one(db) is already taken for optional variant.
I can implement myself if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions