diff --git a/concepts/ORM/Associations/OnetoOne.md b/concepts/ORM/Associations/OnetoOne.md index bcd4094f1..8330132fc 100644 --- a/concepts/ORM/Associations/OnetoOne.md +++ b/concepts/ORM/Associations/OnetoOne.md @@ -14,7 +14,13 @@ There are currently two ways of handling this association in Waterline. In this example, we are associating a `Pet` with a `User`. The `User` may only have one `Pet`, and a `Pet` can only have one `User`. However, in order to query from both sides in this example, we must add a `collection` attribute to the `User` model. This allows us to call both `User.find().populate('pet')` along with `Pet.find().populate('owner')`. -The two models will stay in sync by updating the `Pet` model's `owner` attribute. Adding the `unique` property ensures that only one value for each `owner` will exist in the database. The downside is that when populating from the `User` side, you will always get an array back. +The two models will stay in sync by updating the `Pet` model's `owner` attribute. Adding the `unique` property ensures that only one value for each `owner` will exist in the database. The downside is that when populating from the `User` side, you will always get an array back (`User.find().populate('pet')` will return `[{ pet: [] }]`). + +Further explanation about: + +> The two models will stay in sync by updating the `Pet` model's `owner` attribute. + +If you look into the database, you will see that `pet` column does not exist in the `User` table. This is a virtual field calculated by Waterline. If you look at the `Pet` database, you will see the opposite, you will see a `owner` field there. ```javascript // myApp/api/models/Pet.js