Comparing version 0.8.2 to 0.8.3
@@ -0,1 +1,11 @@ | ||
<a name="0.8.3"></a> | ||
## [0.8.3](https://github.com/boosterfuels/archetype/compare/v0.8.2...v0.8.3) (2018-03-21) | ||
### Features | ||
* support inPlace updates for recursive schemas ([8f61d32](https://github.com/boosterfuels/archetype/commit/8f61d32)), closes [#11](https://github.com/boosterfuels/archetype/issues/11) | ||
<a name="0.8.2"></a> | ||
@@ -2,0 +12,0 @@ ## [0.8.2](https://github.com/boosterfuels/archetype/compare/v0.8.1...v0.8.2) (2017-12-03) |
{ | ||
"name": "archetype", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"author": "Valeri Karpov <val@boosterfuels.com>", | ||
@@ -12,5 +12,5 @@ "dependencies": { | ||
"devDependencies": { | ||
"acquit": "0.4.1", | ||
"acquit": "0.6.1", | ||
"acquit-ignore": "0.0.3", | ||
"acquit-markdown": "0.0.2", | ||
"acquit-markdown": "0.0.8", | ||
"co": "4.6.0", | ||
@@ -21,3 +21,3 @@ "gulp": "3.8.11", | ||
"mocha": "3.5.0", | ||
"mongodb": "~2.2", | ||
"mongodb": "~3.0", | ||
"standard-changelog": "1.0.1" | ||
@@ -24,0 +24,0 @@ }, |
@@ -54,2 +54,4 @@ # archetype | ||
* 20180112: [Virtual Types with Archetype](https://gist.github.com/vkarpov15/32abd9f72dfb2ba1558e9e6a1060c768) | ||
* 20180105: [Transform an Archetype So All Properties are Not Required](https://gist.github.com/vkarpov15/6c49c0bc5ed0eab42633645bf03e8fa7) | ||
* 20171124: [Embedding Only Certain Fields in an Embedded Archetype](https://gist.github.com/vkarpov15/37622608b33eb144acfda5d3ad936be6) | ||
@@ -56,0 +58,0 @@ * 20171117: [Async/Await with Archetype](https://gist.github.com/vkarpov15/f10b560468f49166bcc14c6e41bb755e) |
@@ -28,3 +28,3 @@ 'use strict'; | ||
type.path = (path, props) => this.path(path, props); | ||
type.path = (path, props, opts) => this.path(path, props, opts); | ||
type.omit = path => this.omit(path); | ||
@@ -42,6 +42,10 @@ type.pick = paths => this.pick(paths); | ||
path(path, props) { | ||
path(path, props, options) { | ||
if (!props) { | ||
return _.get(this._obj, path); | ||
} | ||
if (_.get(options, 'inPlace')) { | ||
_.set(this._obj, path, props); | ||
return this; | ||
} | ||
const newSchema = new Archetype(this._obj); | ||
@@ -48,0 +52,0 @@ _.set(newSchema._obj, path, props); |
@@ -345,2 +345,27 @@ 'use strict'; | ||
it('recursive', function() { | ||
let NodeType = new Archetype({ | ||
value: { $type: null } | ||
}).compile('NodeType'); | ||
NodeType. | ||
path('left', { $type: NodeType }, { inPlace: true }). | ||
path('right', { $type: NodeType }, { inPlace: true }). | ||
compile('NodeType'); | ||
const raw = { | ||
value: 'root', | ||
left: { | ||
value: 'left' | ||
}, | ||
right: { | ||
left: { | ||
value: 'right->left' | ||
}, | ||
value: 'right' | ||
} | ||
}; | ||
assert.deepEqual(raw, new NodeType(raw)); | ||
assert.equal(raw.right.left.value, 'right->left'); | ||
}); | ||
it('required function', function() { | ||
@@ -347,0 +372,0 @@ const Person = new Archetype({ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
58793
1421
64
0
17