Skip to content

Insert/Update/... without having to manually specify the column names #676

@omid

Description

@omid

Is it possible to insert or update or ... by not manually mentioning all the columns and get the input from a struct?
If not, is there any plan to add this feature?

For example, instead of:

sqlx::query_as("INSERT INTO todo (description, done) VALUES ($1, $2)")
.bind(&todo.description)
.bind(todo.done)
.await?;

Something like:

//  (table name, struct)
sqlx::insert_by("todo", todo)
.await?;

Or a macro to generate all for us, something like:

//  (table name, struct)
sqlx::replace_by!("todo", todo)
.await?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions