Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created February 21, 2020 03:07
Show Gist options
  • Save Ramko9999/066b68ae95e7bb1a1bab1d52ddb70537 to your computer and use it in GitHub Desktop.
Save Ramko9999/066b68ae95e7bb1a1bab1d52ddb70537 to your computer and use it in GitHub Desktop.
/*
We can do many more vertex attribute operations using the FieldValue class.
*/
//For Incrementing a Number Vertex
FieldValue.increment("THE NUMBER");
//Doing the "OR" operation or "||" on boolean values with new value
FieldValue.logicalOr("THE BOOLEAN");
//Doing the "AND" operation or "&&" on boolean values with new value
FieldValue.logicalAnd("THE BOOLEAN");
//For only overwriting the attribute if the Vertex is created on the upsert request
FieldValue.init("THE VALUE");
//For keeping the Max of two numbers
FieldValue.max("THE NUMBER");
//For keeping the Min of two numbers
FieldValue.min("THE NUMBER");
/*
We can use the FieldValue class by using it as a Value in the attributes field of a Vertex or an Edge
Remeber James, the Person Vertex we just created.
Suppose we wanted to increase his age.
*/
Vertex james = Vertex("Person", "100", attributes: {"age": FieldValue.increment(1)});
await client.upsertVertex(james);
//For those familiar with Cloud Firestore, this is where the FieldValue kind of comes in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment