Skip to content

Drivers

Garry but Spinning edited this page Jul 1, 2021 · 4 revisions

Default Drivers

  • mysqloo: Requires the MySQLOO Module, Also requires conninfo
  • sqlite: No requirements, uses builtin SQL
  • file: Uses files to store data instead of SQL
  • memory: Store all data in RAM, fast but not persistent
  • cache: Based in 2 drivers, source and cache, one for fast picks and one to persist the data

Driver Creation

I highly recommend you use SQLite as an example

  1. Create a file in sqlier/drivers/, this files name will be the name of your driver (aka sqlier/drivers/mysqloo.lua)
  2. From that file return a table with the following methods
    • initialize(table options): Called when driver is included
    • validateSchema(table schema): Called when the schema needs to be validated
    • get(table schema, string identity, function callback(data)): Same as Model:get(identity, callback)
    • find(table schema, string filter, function callback(table data)): Same as Model:find(filter, callback)
    • filter(table schema, string filter, function callback(table data)): Same as Model:filter(filter, callback)
    • update(table schema, table object, function callback): Updates an object
    • increment(table schema, table object, function callback): Atomically increments an object
    • decrement(table schema, table object, function callback): Atomically decrements an object
    • delete(table schema, table identity, function callback(table identity)): Deletes an object from the schema table
    • insert(table schema, table object, function callback(last_insert_rowid)): Inserts a value into the schema table
  3. Done :)
Clone this wiki locally