diff --git a/src/Firebase/ServerValue.cs b/src/Firebase/ServerValue.cs new file mode 100644 index 0000000..e92e2dd --- /dev/null +++ b/src/Firebase/ServerValue.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace Firebase.Database +{ + /// + /// Values that can be used to instruct the Firebase Database to take action based on server value + /// + public static class ServerValue + { + private const string SERVER_VALUE_KEY = ".sv"; + private const string TIME_STAMP_KEY = "timestamp"; + + /// + /// Increments or decreases a number in server side + /// e.g.: valueInFirebaseDatabase = 3 + /// Sending { "valueInFirebaseDatabase", ServerValue.Increment(-1) } + /// results in valueInFirebaseDatabase = 2 + /// + /// the amount you want to increment or decrease(negative values) + /// + public static Dictionary Increment(double value) + => new Dictionary { { SERVER_VALUE_KEY, new { increment = value } } }; + + /// + /// Saves the server time as unix timestamp at the moment of the request + /// + public static Dictionary TimeStamp + => new Dictionary { { SERVER_VALUE_KEY, TIME_STAMP_KEY } }; + } +}