Skip to content

gleam db: insert_book (Create) #18

@HeyItWorked

Description

@HeyItWorked

Sub-issue of #9, depends on #9a (shared helpers)

pub fn insert_book(conn, title, author, status) -> Result(Book, AppError)
  • INSERT INTO books (title, author, status) VALUES ($1, $2, $3) RETURNING id, title, author, status
  • Convert BookStatus to string via status_to_string for the $3 parameter
  • Pattern match returned.rows — expect exactly [book], otherwise DatabaseError

Metadata

Metadata

Assignees

No one assigned

    Labels

    db-layerDatabase/query layergleamGleam implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions