Comparing version 0.5.27 to 0.5.28
@@ -55,2 +55,9 @@ 'use strict'; | ||
(0, _createClass3.default)(Environment, [{ | ||
key: 'init', | ||
value: function init() { | ||
_lodash2.default.each(this.tables, function (table) { | ||
return table.init(); | ||
}); | ||
} | ||
}, { | ||
key: 'createTable', | ||
@@ -57,0 +64,0 @@ value: function createTable(options) { |
@@ -87,3 +87,2 @@ 'use strict'; | ||
var index = _Joi$attempt.index; | ||
// assert.equal(_.has(schema(), pk), true, `'${pk}' is not specified in schema`); | ||
@@ -93,2 +92,3 @@ this.tableName = tableName; | ||
this.schema = schema; | ||
this._schema = null; | ||
this.relations = relations; | ||
@@ -100,7 +100,17 @@ this._relations = null; | ||
(0, _createClass3.default)(Table, [{ | ||
key: 'init', | ||
value: function init() { | ||
this._schema = this.schema(); | ||
this._relations = this.relations(); | ||
} | ||
}, { | ||
key: 'getSchema', | ||
value: function getSchema() { | ||
if (!this._schema) this.init(); | ||
return this._schema; | ||
} | ||
}, { | ||
key: 'getRelations', | ||
value: function getRelations() { | ||
if (!this._relations) { | ||
this._relations = this.relations(); | ||
} | ||
if (!this._relations) this.init(); | ||
return this._relations; | ||
@@ -111,3 +121,3 @@ } | ||
value: function metaFields(metaKey) { | ||
return _lodash2.default.chain(this.schema()).omitBy(function (schema) { | ||
return _lodash2.default.chain(this.getSchema()).omitBy(function (schema) { | ||
return !_lodash2.default.find(schema._meta, function (meta) { | ||
@@ -123,3 +133,3 @@ return _lodash2.default.has(meta, metaKey); | ||
return !_joi2.default.validate(data, this.schema()).error; | ||
return !_joi2.default.validate(data, this.getSchema()).error; | ||
} | ||
@@ -131,3 +141,3 @@ }, { | ||
return _joi2.default.attempt(data, this.schema()); | ||
return _joi2.default.attempt(data, this.getSchema()); | ||
} | ||
@@ -144,3 +154,3 @@ }, { | ||
value: function hasField(fieldName) { | ||
return _lodash2.default.has(this.schema(), fieldName); | ||
return _lodash2.default.has(this.getSchema(), fieldName); | ||
} | ||
@@ -156,3 +166,3 @@ }, { | ||
this.assertField(fieldName); | ||
return this.schema()[fieldName]; | ||
return this.getSchema()[fieldName]; | ||
} | ||
@@ -159,0 +169,0 @@ }, { |
{ | ||
"name": "nothinkdb", | ||
"version": "0.5.27", | ||
"version": "0.5.28", | ||
"description": "Functional toolkit for rethinkdb", | ||
@@ -51,2 +51,3 @@ "main": "lib/nothinkdb.js", | ||
"babel-runtime": "^6.9.0", | ||
"core-decorators": "^0.12.2", | ||
"debug": "^2.2.0", | ||
@@ -53,0 +54,0 @@ "joi": "^7.2.3", |
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
39667
955
7
+ Addedcore-decorators@^0.12.2
+ Addedcore-decorators@0.12.3(transitive)