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

Function ORM

lib/ORM.js:178–215  ·  view source on GitHub ↗
(driver_name, driver, settings)

Source from the content-addressed store, hash-verified

176exports.addAdapter = adapters.add;
177
178function ORM(driver_name, driver, settings) {
179 this.validators = exports.validators;
180 this.enforce = exports.enforce;
181 this.settings = settings;
182 this.driver_name = driver_name;
183 this.driver = driver;
184 this.driver.uid = hat();
185 this.tools = {};
186 this.models = {};
187 this.plugins = [];
188 this.customTypes = {};
189
190 for (var k in Query.Comparators) {
191 this.tools[Query.Comparators[k]] = Query[Query.Comparators[k]];
192 }
193
194 events.EventEmitter.call(this);
195
196 var onError = function (err) {
197 if (this.settings.get("connection.reconnect")) {
198 if (typeof this.driver.reconnect === "undefined") {
199 return this.emit("error", new ORMError("Connection lost - driver does not support reconnection", 'CONNECTION_LOST'));
200 }
201 this.driver.reconnect(function () {
202 this.driver.on("error", onError);
203 }.bind(this));
204
205 if (this.listeners("error").length === 0) {
206 // since user want auto reconnect,
207 // don't emit without listeners or it will throw
208 return;
209 }
210 }
211 this.emit("error", err);
212 }.bind(this);
213
214 driver.on("error", onError);
215}
216
217util.inherits(ORM, events.EventEmitter);
218

Callers

nothing calls this directly

Calls 3

callMethod · 0.80
onMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected