Skip to content

conflict_resolution: Literal["raise", "retrieve"]="raise"


Save an object to the persistent data store. A conflict could be triggered when the object being saved has violated a uniqueness check at the persistent data store. For example, the same object ID could have been used by another record that is already stored.

In these scenarios, we can either raise an error or retrieve the object with the same name, depending on the conflict resolution parameter passed in. The default behavior is to raise an error.


  • conflict_resolution: Literal["raise", "retrieve"]
    default: "raise"
    "raise" will raise an error when we encounter a conflict error.
    "retrieve" will handle the conflict error by retrieving the object with the same name.


  • DuplicatedRecordException
    When a record with the same key exists at the persistent data store.

  • RecordCreationException
    When we fail to save the new object (general failure).


Note that the examples below are not exhaustive.

Save a new Entity object.

>>> entity = fb.Entity(name="grocerycustomer_example", serving_names=["GROCERYCUSTOMERGUID"])
Calling save again returns an error.

>>> entity = fb.Entity(name="grocerycustomer", serving_names=["GROCERYCUSTOMERGUID"])
Entity (id: <>) has been saved before.