import
  db_connector/db_sqlite,
  strutils,
  ../models/models

proc close*(db: DbConn)=
  db.close()

proc setUpFaculty*(db: DbConn) =
  ## setupOrders creates the orders table if it does not exist
  db.exec(sql"""
    CREATE TABLE IF NOT EXISTS faculty (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      first_name VARCHAR(255) NOT NULL,
      last_name VARCHAR(255) NOT NULL,
      email VARCHAR(255) NOT NULL,
      password VARCHAR(255) NOT NULL,
      created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL,
      updated_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL,
      access_level VARCHAR(255) NOT NULL
    );
  """)

proc createPost*(db: DbConn, faculty: Faculty) =
  db.exec(sql"INSERT INTO users (first_name, last_name, email, password, access_level) VALUES (?, ?, ?, ?, ?);", faculty.firstName, faculty.lastName, faculty.email, faculty.password, faculty.accessLevel)
