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

Serialized Model option rather than classes?

reggi opened this issue · comments

commented

I'm curious if there's a way to create a more generic model that allows for you to serialize the table schema. Something like this:

const Flights = model({
  table: 'flights';
  timestamps: true;
  fields: {
    id: { primaryKey: true, autoIncrement: true },
    departure: DataTypes.STRING,
    destination: DataTypes.STRING,
    flightDuration: DataTypes.FLOAT,
  };
  defaults: {
    flightDuration: 2.5,
  };
})

Then perhaps be able to call some more generic method for inserting.

insert('flights', {...data})