0.2.0 • Published 10 years ago
elisa-mysql v0.2.0
MySQL Elisa Driver
MySQL/MariaDB Elisa driver. This driver complies with Elisa 0.5 spec.
Proudly made with ♥ in Valencia, Spain, EU.
Driver load
The driver must be loaded importing the package and then you can use the Driver class
to get the driver:
const Driver = require("elisa-mysql").Driver;
const driver = Driver.getDriver("MySQL");You can also use the MariaDB alias, instead of the MySQL name.
Connections
The options to create a connection:
host(string). The DB server name/IP.port(number). The DB server port.db(string). The database name.username(string). The username.password(string). The password.
Example:
var cx = driver.createConnection({host: "localhost", port: 3306, db: "mydb", username: "root", password: "pwd"});Stores
The stores aren't supported by MySQL and MariaDB natively. These are implemented
using tables with two text columns: id and value:
--without namespace
CREATE TABLE `bands`(id VARCHAR(256) PRIMARY KEY, value TEXT NOT NULL);
--with namespace
CREATE TABLE `my.bands`(id VARCHAR(256) PRIMARY KEY, value TEXT NOT NULL);Collections
Right now, the collections are supported by MySQL natively, but MariaDB doesn't. The Elisa driver only supports the MariaDB collections using tables as:
--without namespace
CREATE TABLE `bands`(id VARCHAR(256) PRIMARY KEY, doc BLOB NOT NULL);
CREATE TABLE `bands`(id int PRIMARY KEY AUTO_INCREMENT, doc BLOB NOT NULL);
--with namespace
CREATE TABLE `my.bands`(id VARCHAR(256) PRIMARY KEY, doc BLOB NOT NULL);
CREATE TABLE `my.bands`(id int PRIMARY KEY AUTO_INCREMENT, doc BLOB NOT NULL);Notes:
- The boolean values are saved as strings with
$starting the value:$trueor$false. The driver converts$truetotrueand$falsetofalseand vice versa. - The array and object values are saved as strings using their JSON representation, starting with
$. The driver does the transformation bidirectional.