This repository has been archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datastore): Add support for projection and distinctOn (#49)
- Loading branch information
1 parent
a74196d
commit 2b5fcc9
Showing
5 changed files
with
118 additions
and
7 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
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
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,32 @@ | ||
from typing import Any # pylint: disable=unused-import | ||
from typing import Dict # pylint: disable=unused-import | ||
|
||
# https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects/runQuery#Projection | ||
|
||
|
||
class Projection(object): | ||
def __init__(self, prop): | ||
# type: (str) -> None | ||
self.prop = prop | ||
|
||
def __eq__(self, other): | ||
# type: (Any) -> bool | ||
if not isinstance(other, Projection): | ||
return False | ||
|
||
return bool(self.prop == other.prop) | ||
|
||
def __repr__(self): | ||
# type: () -> str | ||
return str(self.to_repr()) | ||
|
||
@classmethod | ||
def from_repr(cls, data): | ||
# type: (Dict[str, Any]) -> Projection | ||
return cls(prop=data['property']['name']) | ||
|
||
def to_repr(self): | ||
# type: () -> Dict[str, Any] | ||
return { | ||
'property': {'name': self.prop}, | ||
} |
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
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