Skip to content

Foreign key property (not mapped) #750

@twavv

Description

@twavv

Is your feature request related to a problem? Please describe.
I don't see a way to declare a property as a foreign key (not as a mapped property à la @ManyToOne and friends), which for reasons is something I'd like to do (I'm using dataloader with GraphQL so I mostly am just using Mikro as an easier, type-safe-ish way to access the database).

Describe the solution you'd like
A way to declare a property as a foreign key without doing data mapping.

@Property({
  columnType: "int",
  references: "users(id)"
})
userId: number;

Alternatively, the ability to specify custom constraints (eg as SQL) would be good enough.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions