Drops.Relation.Schema.ForeignKey (drops_relation v0.1.0)

View Source

Represents a foreign key relationship in a database table/schema.

This struct stores information about a foreign key field and its reference to another table and field.

Examples

# Simple foreign key
%Drops.Relation.Schema.ForeignKey{
  field: :user_id,
  references_table: "users",
  references_field: :id
}

Summary

Types

t()

@type t() :: %Drops.Relation.Schema.ForeignKey{
  field: atom(),
  references_field: atom(),
  references_table: String.t()
}

Functions

new(field, references_table, references_field)

@spec new(atom(), String.t(), atom()) :: t()

Creates a new ForeignKey struct.

Parameters

  • field - The foreign key field name in the current table
  • references_table - The name of the referenced table
  • references_field - The field name in the referenced table

Examples

iex> Drops.Relation.Schema.ForeignKey.new(:user_id, "users", :id, :user)
%Drops.Relation.Schema.ForeignKey{
  field: :user_id,
  references_table: "users",
  references_field: :id
}