eveningkid / denodb

MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno

Home Page:https://eveningkid.com/denodb-docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Foreign key column name customisable?

tclzcja opened this issue · comments

Hi there, just wonder is it in the current API that we can customise the foreign key column name for 1-1/1-n/n-1/n-m relationship? I didn't find it in the readme.

Maybe something like:

class Owner extends Model {
  static table = 'owners';

  static fields = {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    name: DataTypes.STRING,
    business_id: {
      type: DataTypes.UUID,
      foreignKey: {
          model: Business,
          columnName: "id"
      }
    }
  };
}

or

Relationships.belongsTo(Business, Owner, { columnName: "owner_id" });

Naming convention is some sort of important for a project, and we can't assume everyone will name the columns in camelCase right?