Freeswitch: native PostreSQL from Javascript (mod_v8)
Implement native PostgreSQL in JavaScript by adding a Database Handler (DBH) class
- Реализация DBH PostgresSQL в mod_v8
- Freeswitch >= v1.8.0
- Методы JS такие же как в LUA's Dbh.
Пример:
use("DBH"); consoleLog("info", "DBH TEST"); var db_connection_string = "pgsql://host=example.com dbname=my_db user=john password='johnpass' options='-c client_min_messages=NOTICE' application_name='freeswitch'"; var dbh = new DBH(db_connection_string); consoleLog("info", "DB STATUS: " + dbh.connected()); dbh.test_reactive("SELECT * FROM my_table", "DROP TABLE my_table", "CREATE TABLE my_table (id numeric, name VARCHAR(255))"); dbh.query("INSERT INTO my_table (id, name) VALUES (1, 'name1'), (2, 'name2');"); dbh.query("SELECT id, name FROM my_table;", function(row){ consoleLog("info", "DB ROW - ID: " + row.id + " NAME: " + row.name); }); consoleLog("info", "DSN: " + dbh.dsn); consoleLog("info", "AFFECTED: " + dbh.affected_rows()); consoleLog("info", "LAST ERROR: " + dbh.last_error()); // Unnecessary //dbh.release();