Skip to main content

upsert_entity

Function upsert_entity 

Source
pub fn upsert_entity<F: Fs>(
    db: &mut GraphDb<F>,
    key: &str,
    label: Option<&str>,
    row: BTreeMap<String, Value>,
    aliases: &[String],
) -> Result<UpsertOutcome>
Expand description

Create or update one entity by key, with the policy every surface shares.

  • id is never taken from row: on a create it is set to key, and on an update it is left alone.
  • A create needs label. An update never changes one: a label that differs from the stored one is refused before anything is written, so nothing in row is applied either.
  • A row entry ns equal to the namespace the node is already in is the engine’s no-op and is not counted as an update; a different one is the engine’s NamespaceImmutable refusal.
  • Aliases are maintained and a provisional mark is cleared, as describe_entity_with_aliases does.
  • A key that is empty or only whitespace is refused before anything is read or written, whether or not a node is stored under it.
  • A create under a label that is empty or only whitespace is refused before anything is written, by describe_entity_with_aliases. On an update such a label is the relabel refusal above, like any other label the node does not carry.

Reads and writes on the one &mut handle, so the existence check and the write cannot be separated by another writer.

§Errors

GraphError::IngestError for the four policy refusals, with the whole sentence in detail; any engine refusal, as it came.