def get_content_from_snapshot(self, doc: DocumentSnapshot) -> Dict:
     """
     Method for getting document content from snapshot of document
     :param doc: Snapshot of document
     :return: dict with document's content
     """
     return doc.to_dict()
Esempio n. 2
0
 def build_data(price: DocumentSnapshot) -> dict:
     data = price.to_dict()
     return {
         'date': data['date'],
         'code': data['code'],
         'opening_quotation': data['opening_quotation'],
         'high': data['high'],
         'turnover': data['turnover'],
         'closing_quotation': data['closing_quotation'],
         'low': data['low']
     }
Esempio n. 3
0
def parse_cursor(cursor, client):
    from google.cloud.firestore_v1beta1 import DocumentReference
    from google.cloud.firestore_v1beta1 import DocumentSnapshot

    if cursor.HasField("doc_snapshot"):
        path = parse_path(cursor.doc_snapshot.path)
        doc_ref = DocumentReference(*path, client=client)

        return DocumentSnapshot(
            reference=doc_ref,
            data=json.loads(cursor.doc_snapshot.json_data),
            exists=True,
            read_time=None,
            create_time=None,
            update_time=None,
        )

    values = [json.loads(value) for value in cursor.json_values]
    return convert_data(values)