Commit bcb8692b by johnk

Incorporated suggestions

Changed some comments. Rewrote part of the documentation.
parent fa21c7df
...@@ -373,9 +373,12 @@ for post in posts_by_joe: ...@@ -373,9 +373,12 @@ for post in posts_by_joe:
Relations Relations
--------- ---------
You can associate multiple objects to a single object A Relation is field that contains references to multiple objects.
by using a Relation. You can query this subset of objects.
You then query against this subset of objects.
For example, if we have Game and GameScore classes, and one game
can have multiple GameScores, you can use relations to associate
those GameScores with a Game.
~~~~~ {python} ~~~~~ {python}
game = Game(name="3-way Battle") game = Game(name="3-way Battle")
...@@ -388,7 +391,7 @@ relation.add([score1, score2, score3]) ...@@ -388,7 +391,7 @@ relation.add([score1, score2, score3])
~~~~~ ~~~~~
A Game gets added, three GameScores get added, and three relations A Game gets added, three GameScores get added, and three relations
are created associating the scores with the game. are created associating the GameScores with the Game.
To retreive the related scores for a game, you use query() to get a To retreive the related scores for a game, you use query() to get a
Queryset for the relation. Queryset for the relation.
...@@ -399,7 +402,6 @@ for gamescore in scores: ...@@ -399,7 +402,6 @@ for gamescore in scores:
print gamescore.player_name, gamescore.score print gamescore.player_name, gamescore.score
~~~~~ ~~~~~
The Queryset can be manipulated like any Queryset.
The query is limited to the objects previously added to the The query is limited to the objects previously added to the
relation. relation.
......
...@@ -145,12 +145,12 @@ class Relation(ParseType): ...@@ -145,12 +145,12 @@ class Relation(ParseType):
queries until we know what classes are on both sides queries until we know what classes are on both sides
of the relation. of the relation.
If it's called via from_native, then, a later call to If it's called via from_native, then a later call to
with_parent() provides parent information. with_parent() provides parent information.
If it's called as Relation(), the relatedClassName is If it's called as Relation(), the relatedClassName is
discovered either on the first added object, or discovered either on the first added object, or
by probing the server to retrieve an object. by querying the server to retrieve the schema.
""" """
# Name of the key on the parent object. # Name of the key on the parent object.
self.key = None self.key = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment