Skip to content

Working with auto increment IDs #80

@Slesa

Description

@Slesa

Consider an order with an auto ID field, which can have multiple orderlines.

type Order = { Id: int64 option }
type OrderLine = { Id: int64 option; order: int64 }

Is there an example how to get the value of this generated ID in order to use it as the reference in the orderlines?
I know this can be done manually with

INSERT INTO Order(...) values(...) SELECT SCOPE_IDENTITY()

or "; SELECT last_insert_rowid()" for MSSql/Postgres

but maybe there is a more comfortable way?

And probably there is no other way than keep the ID as option, isn't it?

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