xpress-mongo
Advanced tools
Comparing version 0.0.58 to 0.0.59
@@ -72,10 +72,36 @@ "use strict"; | ||
model(collection, model) { | ||
const connection = this.collection(collection); | ||
if (model) { | ||
model.native = function () { | ||
return connection; | ||
}; | ||
return model; | ||
try { | ||
const connection = this.collection(collection); | ||
if (model) { | ||
model.native = function () { | ||
return connection; | ||
}; | ||
return model; | ||
} | ||
else { | ||
/** | ||
* Extend XMongoModel | ||
*/ | ||
return class extends XMongoModel { | ||
/** | ||
* Use `.native()` instead | ||
* @deprecated since (v 0.0.40) | ||
* @remove at (v 1.0.0) | ||
*/ | ||
static thisCollection() { | ||
console.error('Model.thisCollection() is deprecated, use .native() instead.'); | ||
return connection; | ||
} | ||
; | ||
/** | ||
* Returns native mongodb instance to run native queries | ||
*/ | ||
static native() { | ||
return connection; | ||
} | ||
; | ||
}; | ||
} | ||
} | ||
else { | ||
catch (e) { | ||
/** | ||
@@ -85,19 +111,2 @@ * Extend XMongoModel | ||
return class extends XMongoModel { | ||
/** | ||
* Use `.native()` instead | ||
* @deprecated since (v 0.0.40) | ||
* @remove at (v 1.0.0) | ||
*/ | ||
static thisCollection() { | ||
console.error('Model.thisCollection() is deprecated, use .native() instead.'); | ||
return connection; | ||
} | ||
; | ||
/** | ||
* Returns native mongodb instance to run native queries | ||
*/ | ||
static native() { | ||
return connection; | ||
} | ||
; | ||
}; | ||
@@ -104,0 +113,0 @@ } |
{ | ||
"name": "xpress-mongo", | ||
"version": "0.0.58", | ||
"version": "0.0.59", | ||
"description": "Light Weight ODM for mongoDb", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
@@ -91,34 +91,39 @@ import XMongoModel = require('./XMongoModel'); | ||
model(collection: string, model?: typeof XMongoModel): typeof XMongoModel { | ||
const connection: Collection = this.collection(collection); | ||
try { | ||
const connection: Collection = this.collection(collection); | ||
if (model) { | ||
model.native = function (): Collection { | ||
return connection | ||
if (model) { | ||
model.native = function (): Collection { | ||
return connection | ||
} | ||
return model; | ||
} else { | ||
/** | ||
* Extend XMongoModel | ||
*/ | ||
return <typeof XMongoModel><unknown>class extends XMongoModel { | ||
/** | ||
* Use `.native()` instead | ||
* @deprecated since (v 0.0.40) | ||
* @remove at (v 1.0.0) | ||
*/ | ||
static thisCollection(): Collection { | ||
console.error('Model.thisCollection() is deprecated, use .native() instead.') | ||
return connection; | ||
}; | ||
/** | ||
* Returns native mongodb instance to run native queries | ||
*/ | ||
static native(): Collection { | ||
return connection; | ||
}; | ||
} | ||
} | ||
return model; | ||
} else { | ||
} catch (e) { | ||
/** | ||
* Extend XMongoModel | ||
*/ | ||
return <typeof XMongoModel><unknown>class extends XMongoModel { | ||
/** | ||
* Use `.native()` instead | ||
* @deprecated since (v 0.0.40) | ||
* @remove at (v 1.0.0) | ||
*/ | ||
static thisCollection(): Collection { | ||
console.error('Model.thisCollection() is deprecated, use .native() instead.') | ||
return connection; | ||
}; | ||
/** | ||
* Returns native mongodb instance to run native queries | ||
*/ | ||
static native(): Collection { | ||
return connection; | ||
}; | ||
} | ||
return <typeof XMongoModel><unknown>class extends XMongoModel {} | ||
} | ||
} | ||
@@ -125,0 +130,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147921
4445