go-bongo / bongo

Go ODM for MongoDB
MIT License
487 stars 40 forks source link

Not sure what "Cascading" does? #20

Closed lucaswxp closed 7 years ago

lucaswxp commented 7 years ago

hey guys.

Sorry for the noob question, but I couldn't understand what "cascade" actually means in this sentence:

you can cascade a player's first name and last name to his or her team.Players array on save, and remove that element in the array if you delete the player.

Supposing I have the following "team", in what could cascade help-me?

[
    {
        "team": "Team A",
        "players": [
            {
                "firstname": "Player",
                "lastname": "1"
            },
            {
                "firstname": "Player",
                "lastname": "2"
            },
            {
                "firstname": "Player",
                "lastname": "3"
            }
        ]
    }
]
securingsincity commented 7 years ago

@lucaswxp the idea is that the Team's players could be managed through the team. In the example, the behavior is similar to how an ORM would manage a one-to-many relationship. In bongo one document contains all of those elements. If you update a child element it will update the parent, in this case the team. In this example, a player whose name is updated will update the team and update the player inside the team.

lucaswxp commented 7 years ago

@securingsincity I think I got it. Thanks!