Array of Objects using Factory.get
See original GitHub issueI’ve the impression that this is yet another use case that it is not supported at the moment. #15 and #14 seems related to this one, but not quite.
Running this define
I get a RangeError: Maximum call stack size exceeded
Error …
Factory.define('fakeTeam',Volunteers.Collections.Teams,
{
'name': () -> faker.company.companyName()
'visibility': 'public',
'leads': () -> [ {'userId': Factory.get('fakeUser'), 'role': 'lead'} ]
'tags': () -> [faker.lorem.words()],
'parents':[],
})
I can’t find a better title to describe this problem …
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Pushing Objects From Function Factories into Arrays
I want to have a function that takes the difference between the total zombie health versus total human attack. It works with one...
Read more >How to Create Objects Using Factory Functions in JavaScript
This article will cover building an object using factory functions, followed by an article covering constructor functions and using the new ...
Read more >JavaScript Factory Functions
A factory function is a function that returns a new object. Use Object.create() to create an object using an existing object as a...
Read more >Factory: Encapsulating Object Creation
The actual creation of shapes is performed by calling ShapeFactory.createShape( ), which is a static method that uses the dictionary in ShapeFactory to...
Read more >Factory Method - Refactoring.Guru
The Factory Method pattern suggests that you replace direct object construction calls (using the new operator) with calls to a special factory method....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks like what you’re trying to do isn’t supported yet 😔, as you can see by this test: https://github.com/versolearning/meteor-factory/blob/master/factory_tests.js#L337-L346
In the meantime you can just do this:
The only downside to this would be if you wished to use
Factory.tree
, though I wouldn’t imagine your intention would be to store the complete user document within the array.Another solution might be something like :
and
'leads': function() { return [{'userId': getRandomUser()._id, 'role': 'lead'}]; }