package schema

import "gorm.io/gorm"

type LocalDriver struct {
	db *gorm.DB
}

func (driver *LocalDriver) Columns(module, table string) []*Schema {
	vs := make([]*Schema, 0)
	driver.db.Where("module_name=? AND table_name=?", module, table).Find(&vs)
	return vs
}

func (driver *LocalDriver) DeleteColumn(id int) (err error) {
	return driver.db.Where("id=?", id).Delete(&Schema{}).Error
}

func (driver *LocalDriver) SaveColumn(schema *Schema) (err error) {
	return driver.db.Save(schema).Error
}
