Adding & Deleting Entities (Records)

Intro #

TrackZero uses what is known as Upsert (Update or Insert). Creating an Entity or updating it uses the same operation. This allows undeterministic creation of Entities (Or updating), which means you don’t have to remember the state of an Entity in order to determine whether you need to update or create.

Upsert an Entity #

					analytics_space_id = "python-example-space"

order = Entity("Orders", 712) \
            .add_attribute("Time", datetime.utcnow()) \
            .add_attribute("Total Amount", uuid4()) \
            .add_entity_reference_attribute("Items", "Products", 1) \
            .add_entity_reference_attribute("Items", "Products", 2) \
            .add_entity_reference_attribute("Order By", "Customers", 23) \
            .add_automatically_translated_geopoint(52.51059, -2.17762)

trackZero_client.upsert_entity(order, analytics_space_id)

Delete an Entity #

					trackZero_client.delete_entity(analytics_space_id, "Orders", 712)