Created
February 21, 2020 03:07
-
-
Save Ramko9999/066b68ae95e7bb1a1bab1d52ddb70537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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