Created
July 25, 2018 20:19
-
-
Save tseaver/196a26f3ebeaa08e9f63260e39e6843b to your computer and use it in GitHub Desktop.
GCP #5111: sample showing nested 'exclude_from_indexes'
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
import datetime | |
import uuid | |
from google.cloud import datastore | |
def main(): | |
ds = datastore.Client() | |
data = { | |
'timestamp': datetime.datetime.utcnow(), | |
'test1': 'test 111', | |
'test2': 'test 2', | |
'long_text': 'LONG_TEXT_HERE', | |
} | |
flow_children = [ | |
datastore.Entity(exclude_from_indexes=['long_text']) | |
] | |
for child in flow_children: | |
child['long_text'] = 'LONG_TEXT_HERE' | |
_id = str(uuid.uuid4()) | |
key = ds.key('Test', _id) | |
entity = datastore.Entity( | |
key=key, | |
exclude_from_indexes=['long_text', 'flow_children']) | |
entity.update(data) | |
entity['flow_children'] = flow_children | |
ds.put(entity) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment