This file contains hidden or 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
; function findItem() { ; | |
; var item ; | |
; while(item_not_found) { ; | |
// search | |
; } ; | |
; return item ; | |
; } ; | |
; var item = findItem() ; |
This file contains hidden or 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
from google.cloud import firestore | |
from time import sleep | |
# Add a new document | |
db = firestore.Client() | |
doc_ref = db.collection(u'live_news').document(u'2019-01-31') | |
def pad_message(m): | |
pad_size = len(m) | |
return u'\u00A0'*pad_size + m + u'\u00A0'*(pad_size+1) |
This file contains hidden or 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
# Create example call center data | |
# Each agent has their own subcollection of calls | |
# You can run this generator multiple times in parallel | |
from google.cloud import firestore | |
import random | |
# Default values create 5000 documents. | |
MAX_AGENTS = 100 | |
MAX_CALLS = 50 | |
MAX_RATING = 5 |
This file contains hidden or 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
# Query example call center data | |
# Demonstrates both collection queries and collection group queries | |
# Data generated via https://gist.github.com/dmcgrath/0c404b5f2f17f1383e4f14631e579783 | |
from google.cloud import firestore | |
db = firestore.Client(project="<your project id here>") | |
review_calls = db.collection_group(u'calls').where(u'sample',u'<',5).limit(5) | |
call_docs = review_calls.get() | |
for call_doc in call_docs: |
OlderNewer