Skip to content

Commit b705c0c

Browse files
Merge pull request #400 from jntesteves/feature/doc-setupInstance
docs: fix description and example of BaseModel.setupInstance()
2 parents 528dc86 + 6ebf78c commit b705c0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/model-classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ One important note, the `isAdmin` attribute is specified in the above example in
146146

147147
A new `setupinstance` class method is now available in version 2.0. This method allows you to transform the data and setup the final instance based on incoming data. For example, you can access the `models` object to reference other service Model classes and create data associations.
148148

149-
The function will be called with the following arguments and should return an object of default properties for new instances.
149+
The function will be called during model instance construction with the following arguments and should return an object containing properties that'll be merged into the new instance.
150150

151151
- `data {Object}` - The instance data
152152
- A `utils` object containing these props:
@@ -160,7 +160,7 @@ For an example of how you might use `setupInstance`, suppose we have two service
160160
setupInstance(data, { store, models }) {
161161
if (data.posts) {
162162
// Turn posts into an array of Post instances
163-
data.posts = data.posts.map(p => new models.Todo(p))
163+
data.posts = data.posts.map(post => new models.Post(post))
164164
}
165165
return data
166166
}

0 commit comments

Comments
 (0)