Comparing version 2.0.0 to 2.0.1
@@ -0,1 +1,6 @@ | ||
## 2.0.1/2016-09-06 | ||
- change built-in schema plugin's name `schema` -> `MongolassSchema` | ||
- repeatedly callling `mongolass.connect` will throw error | ||
## 2.0.0/2016-09-03 | ||
@@ -2,0 +7,0 @@ |
@@ -37,8 +37,11 @@ 'use strict'; | ||
connect(url, opts) { | ||
if (this._db) { | ||
if (url) { | ||
return Promise.reject(new Error(`Already connected to ${this._url}, please create another connection.`)); | ||
} | ||
return Promise.resolve(this._db); | ||
} | ||
this._url = url || this._url; | ||
this._opts = opts || this._opts; | ||
if (this._db) { | ||
return Promise.resolve(this._db); | ||
} | ||
this._conn = this._conn || mongodb.MongoClient | ||
@@ -45,0 +48,0 @@ .connect(this._url, this._opts) |
@@ -44,3 +44,3 @@ 'use strict'; | ||
this._plugins = [{ | ||
name: 'schema', | ||
name: 'MongolassSchema', | ||
hooks: plugins(ctx._schema), | ||
@@ -47,0 +47,0 @@ args: [] |
{ | ||
"name": "mongolass", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Elegant MongoDB driver for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -67,3 +67,3 @@ ## Mongolass | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeInsertOne', | ||
@@ -70,0 +70,0 @@ args: [] } |
@@ -24,2 +24,3 @@ 'use strict'; | ||
it('connect', function* () { | ||
let error; | ||
let db = yield mongolass.connect(); | ||
@@ -31,2 +32,9 @@ assert.ok(db instanceof Db); | ||
assert.ok(db === db2); | ||
try { | ||
yield mongolass.connect('mongodb://localhost:27018/test'); | ||
} catch (e) { | ||
error = e; | ||
} | ||
assert.deepEqual(error.message, 'Already connected to mongodb://localhost:27017/test, please create another connection.'); | ||
}); | ||
@@ -33,0 +41,0 @@ |
@@ -63,3 +63,3 @@ 'use strict'; | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeBulkWrite', | ||
@@ -81,3 +81,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeBulkWrite', | ||
@@ -99,3 +99,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeBulkWrite', | ||
@@ -138,3 +138,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeBulkWrite', | ||
@@ -512,3 +512,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeFindAndModify', | ||
@@ -573,3 +573,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeFindOneAndReplace', | ||
@@ -594,3 +594,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeFindOneAndUpdate', | ||
@@ -615,3 +615,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeInsert', | ||
@@ -636,3 +636,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeInsertOne', | ||
@@ -657,3 +657,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeInsertMany', | ||
@@ -694,3 +694,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeReplaceOne', | ||
@@ -715,3 +715,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeSave', | ||
@@ -741,3 +741,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -766,3 +766,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -795,3 +795,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -816,3 +816,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -851,3 +851,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -955,3 +955,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -973,3 +973,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdate', | ||
@@ -995,3 +995,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdateOne', | ||
@@ -1016,3 +1016,3 @@ args: [] | ||
model: 'User', | ||
plugin: 'schema', | ||
plugin: 'MongolassSchema', | ||
type: 'beforeUpdateMany', | ||
@@ -1019,0 +1019,0 @@ args: [] |
68693
1885