MCPcopy Create free account
hub / github.com/dresende/node-orm2 / Driver

Function Driver

lib/Drivers/DML/postgres.js:63–111  ·  view source on GitHub ↗
(config, connection, opts)

Source from the content-addressed store, hash-verified

61};
62
63function Driver(config, connection, opts) {
64 var functions = switchableFunctions.client;
65
66 this.dialect = 'postgresql';
67 this.config = config || {};
68 this.opts = opts || {};
69
70 if (!this.config.timezone) {
71 this.config.timezone = "local";
72 }
73
74 this.query = new Query({ dialect: this.dialect, timezone: this.config.timezone });
75 this.customTypes = {};
76
77 if (connection) {
78 this.db = connection;
79 } else {
80 if (this.config.query && this.config.query.ssl) {
81 config.ssl = true;
82 this.config = _.extend(this.config, config);
83 // } else {
84 // this.config = _.extend(this.config, config);
85 // this.config = config.href || config;
86 }
87
88 pg.types.setTypeParser(20, Number);
89
90 if (opts.pool) {
91 functions = switchableFunctions.pool;
92 this.db = new pg.Pool(this.config);
93 } else {
94 this.db = new pg.Client(this.config);
95 }
96 }
97
98 _.extend(this.constructor.prototype, functions);
99
100 this.constructor.prototype.execSimpleQueryAsync = Promise.promisify(this.constructor.prototype.execSimpleQuery);
101
102 this.aggregate_functions = [
103 "ABS", "CEIL", "FLOOR", "ROUND",
104 "AVG", "MIN", "MAX",
105 "LOG", "EXP", "POWER",
106 "ACOS", "ASIN", "ATAN", "COS", "SIN", "TAN",
107 "RANDOM", "RADIANS", "DEGREES",
108 "SUM", "COUNT",
109 "DISTINCT"
110 ];
111}
112
113_.extend(Driver.prototype, shared, DDL);
114

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected