Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add __parent reference to embedded models
Add a new hidden property `__parent` that's automatically set on all instances of embedded models. For backwards compatibility, this feature is not enabled by default. You can turn it on by adding the following line to `server/server.js` file: app.registry.modelBuilder.settings.parentRef = true;
- Loading branch information
Showing
8 changed files
with
285 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
/** | ||
* Helper function that when called should return the current instance of the modelBuilder | ||
* @param {function: ModelBuilder} getBuilder | ||
*/ | ||
const createTestSetupForParentRef = (getBuilder) => { | ||
assert.strictEqual(typeof getBuilder, 'function', 'Missing getter function for model builder'); | ||
const settingProperty = 'parentRef'; | ||
beforeEach('enabling parentRef for given modelBuilder', () => { | ||
const modelBuilder = getBuilder(); | ||
assert(modelBuilder && typeof modelBuilder === 'object', 'Invalid modelBuilder instance'); | ||
modelBuilder.settings[settingProperty] = true; | ||
}); | ||
afterEach('Disabling parentRef for given modelBuilder', () => { | ||
const modelBuilder = getBuilder(); | ||
assert(modelBuilder && typeof modelBuilder === 'object', 'Invalid modelBuilder instance'); | ||
modelBuilder.settings[settingProperty] = false; | ||
}); | ||
}; | ||
|
||
module.exports = createTestSetupForParentRef; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.