This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modeling relationship between games, players and achievements (Issue #6)
- Loading branch information
Showing
4 changed files
with
65 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__all__ = ['model'] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from py2neo.ogm import Property, GraphObject, RelatedTo, RelatedFrom | ||
|
||
|
||
class BaseObject(GraphObject): | ||
def to_dict(self): | ||
return self.__ogm__.node | ||
|
||
|
||
class Game(BaseObject): | ||
__primarykey__ = "id" | ||
|
||
id = Property() | ||
name = Property() | ||
|
||
achievements = RelatedTo("Achievement", "hasAchievement") | ||
owned_by = RelatedFrom("Player", "ownedBy") | ||
|
||
|
||
class Achievement(BaseObject): | ||
__primarykey__ = "id" | ||
|
||
id = Property() | ||
name = Property() | ||
description = Property() | ||
image_url = Property(key="imageUrl") | ||
source = Property() | ||
|
||
achieved_in = RelatedFrom("Game", "achievedIn") | ||
|
||
|
||
class Player(BaseObject): | ||
# TODO: use a global unique identifier | ||
__primarykey__ = "name" | ||
|
||
name = Property() | ||
|
||
games = RelatedTo("Game", "owns") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters