Active Record Lite
var seventyEight = ; moduleexports = seventyEight;
Initialize
Configure DB connection at runtime:
DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_SCHEMA, DEBUG
Documentation
API
// model creationseventyEight;
Static Methods
all()
// return all records according to any conditionals appliedUserall;
select()
// Array or csv syntaxUserUser
one()
User;
joins()
User
where()
// simple JS object AND concatenationUser // WHERE admin = 1 // OR using a distributive syntaxUser // WHERE admin = 1 OR access = 1 // multiple where statements with custom comparatorsUser; // WHERE `id` = 1 AND `id` != 1 AND `id` >= 1 // multi-level AND OR compositionsUser // WHERE (`name` = 'root' OR (`title` = 'manager' AND (`updated` = 0 OR `deleted` = 1)))
order()
group()
limit()
then()
Instance Methods
save()
var user = name: 'Wiley Bennett' admin: 1 ;user;
update()
delete()
afterFind()
var seventyEight = ; moduleexports = seventyEight;
beforeSave(properties)
var seventyEight = ; moduleexports = seventyEight;
Literal SQL
Write literal SQL by using the connector:
seventyEightdb ;
Development
Run tests
Create a .env
file with your local MySQL connection credentials
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=root
DB_PORT=3306
DB_SCHEMA=seventy_eight