module Rodauth::Model::Sequel

def define_association(model, type:, name:, table:, key:, **options)

def define_association(model, type:, name:, table:, key:, **options)
  associated_model = Class.new(::Sequel::Model)
  associated_model.set_dataset(model.db[table])
  associated_model.many_to_one :account, class: model.name, key: key
  model.const_set(camelize(singularize(name.to_s)), associated_model)
  model.public_send type, name,
    class: associated_model.name,
    key: key,
    **options,
    **association_options(name)
  model.add_association_dependencies name => :delete
end