不要怂,就是干,撸起袖子干!

Commit 05c4b1fb by superclarkk

Update models-usage.md

Clarify the phrases, "Notice that the accessor is singular/plural" - which may be confusing as the term, "accessor", typically refers to code
1 parent a8fe9310
Showing with 3 additions and 2 deletions
...@@ -443,7 +443,7 @@ Task.findAll({ include: [ User ] }).then(function(tasks) { ...@@ -443,7 +443,7 @@ Task.findAll({ include: [ User ] }).then(function(tasks) {
}) })
``` ```
Notice that the accessor is singular as the association is one-to-something. Notice that the accessor (the `User` property in the resulting instance) is singular because the association is one-to-something.
Next thing: Loading of data with many-to-something associations! Next thing: Loading of data with many-to-something associations!
...@@ -469,7 +469,8 @@ User.findAll({ include: [ Task ] }).then(function(users) { ...@@ -469,7 +469,8 @@ User.findAll({ include: [ Task ] }).then(function(users) {
}) })
``` ```
Notice that the accessor is plural. This is because the association is many-to-something. Notice that the accessor (the `Tasks` property in the resulting instance) is plural because the association is many-to-something.
If an association is aliased (using the `as` option), you must specify this alias when including the model. Notice how the user's `Tool`s are aliased as `Instruments` above. In order to get that right you have to specify the model you want to load, as well as the alias: If an association is aliased (using the `as` option), you must specify this alias when including the model. Notice how the user's `Tool`s are aliased as `Instruments` above. In order to get that right you have to specify the model you want to load, as well as the alias:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!