Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

Add Foreign Key Support #54

@kingmesal

Description

@kingmesal

Adding on to #53 ...

For foreign keys there are a number of options a foreign key may have, but from a definition standpoint adding the foreign key to the column definition make the most sense as each column may only reference a single foreign column.

What I propose is the following:

{
  username: {
    type: DataTypes.STRING,
    unique: "some-arbitrary-key",
  },
  session: {
    type: DataTypes.STRING,
    foreignKey: {
      table: "session-table", // example like Model.tableName
      column: "session-table-field-name", // example like Model.columnName
      onDelete?: {
          cascade?: boolean,
          restrict?: boolean,
          setNull?: boolean,
          setDefault?: boolean,
      },
      onUpdate?: {
          cascade?: boolean,
          restrict?: boolean,
          setNull?: boolean,
          setDefault?: boolean,
      },
    },
  },
}

I think this approach is fairly straight-forward and easy to follow.

Thoughts?

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