Fauna csharp driver  4.2.0
Public Member Functions | Static Public Member Functions | List of all members
FaunaDB.Types.Value Class Reference

Represents any scalar or non-scalar value in the FaunaDB query language. FaunaDB value types consist of all of the JSON value types, as well as the FaunaDB-specific types, RefV and SetRefV. More...

Inheritance diagram for FaunaDB.Types.Value:
FaunaDB.Query.Expr FaunaDB.Types.ArrayV FaunaDB.Types.NullV FaunaDB.Types.ObjectV FaunaDB.Types.ScalarValue< TWrapped >

Public Member Functions

Value At (params string[] keys)
 Navigate through object's keys, assuming value is an instance of ObjectV. More...
 
Value At (params int[] indexes)
 Navigate through array's indexes, assuming value is an instance of ArrayV. More...
 
IResult< T > To< T > ()
 Attempts to coerce this value to given type T specified. More...
 
IReadOnlyList< T > Collect< T > (Field< T > field)
 Loop through this node collecting the Field passed, assuming the node is an instance of ArrayV More...
 
Get< T > (Field< T > field)
 Extract a Field from this node More...
 
IOption< T > GetOption< T > (Field< T > field)
 Attempts to extact a Field from this node More...
 
- Public Member Functions inherited from FaunaDB.Query.Expr
override bool Equals (object obj)
 
abstract bool Equals (Expr v)
 
override int GetHashCode ()
 

Static Public Member Functions

static implicit operator Value (bool b)
 
static implicit operator Value (double d)
 
static implicit operator Value (long l)
 
static implicit operator Value (int i)
 
static implicit operator Value (string s)
 
static implicit operator Value (DateTime dt)
 
static implicit operator Value (DateTimeOffset dt)
 
static implicit operator Value (byte[] bytes)
 
static operator bool (Value v)
 
static operator double (Value v)
 
static operator long (Value v)
 
static operator string (Value v)
 
static operator DateTime (Value v)
 
static operator DateTimeOffset (Value v)
 
- Static Public Member Functions inherited from FaunaDB.Query.Expr
static bool operator== (Expr a, Expr b)
 
static bool operator!= (Expr a, Expr b)
 
static implicit operator Expr (bool b)
 
static implicit operator Expr (double d)
 
static implicit operator Expr (long l)
 
static implicit operator Expr (int i)
 
static implicit operator Expr (string s)
 
static implicit operator Expr (DateTime dt)
 
static implicit operator Expr (DateTimeOffset dt)
 
static implicit operator Expr (Dictionary< string, Expr > dict)
 
static implicit operator Expr (byte[] bytes)
 
static implicit operator Expr (ActionType action)
 
static implicit operator Expr (TimeUnit unit)
 
static implicit operator Expr (Normalizer normalizer)
 
static operator bool (Expr v)
 
static operator double (Expr v)
 
static operator long (Expr v)
 
static operator string (Expr v)
 
static operator DateTime (Expr v)
 
static operator DateTimeOffset (Expr v)
 
static operator ActionType (Expr v)
 
static operator TimeUnit (Expr unit)
 
static operator Normalizer (Expr normalizer)
 

Additional Inherited Members

- Protected Member Functions inherited from FaunaDB.Query.Expr
abstract int HashCode ()
 

Detailed Description

Represents any scalar or non-scalar value in the FaunaDB query language. FaunaDB value types consist of all of the JSON value types, as well as the FaunaDB-specific types, RefV and SetRefV.

Scalar values are LongV, StringV, DoubleV, BooleanV, NullV, RefV, and SetRefV.

Non-scalar values are ObjectV and ArrayV.

This interface itself does not have any directly accessible data. It must first be coerced into a type before its data can be accessed.

See FaunaDB Value Types

Consider the Value node modeling the root of the tree:

{
"ref": { "@ref": { "id": "classes" } },
"data": { "someKey": "string1", "someKey2": 123 }
}

The result tree can be accessed using:

Field<RefV> ref = Field.At("ref").To<RefV>();
Field<string> someKey = Field.At("data", "someKey").To<string>();
Field<string> nonExistingKey = Field.At("non-existing-key").To<long>();
node.Get(ref); // new RefV("classes")
node.Get(someKey); // "string1"
node.GetOption(nonExistingKey) // Option.None<string>()

The interface also has helpers to transverse values without Field references:

node.At("ref").To<RefV>().Get(); // new RefV("classes")
node.At("data", "someKey").To<string>().Get() // "string1"
node.At("non-existing-key").To<long>().GetOption() // Option.None<long>()
Value At(params string[] keys)
Navigate through object's keys, assuming value is an instance of ObjectV.

See Field

Definition at line 59 of file Value.cs.

Member Function Documentation

◆ At() [1/2]

Value FaunaDB.Types.Value.At ( params int[]  indexes)

Navigate through array's indexes, assuming value is an instance of ArrayV.

Parameters
indexesindexes path to navigate to
Returns
Value under the path or NullV

◆ At() [2/2]

Value FaunaDB.Types.Value.At ( params string[]  keys)

Navigate through object's keys, assuming value is an instance of ObjectV.

Parameters
keyskeys path to navigate to
Returns
Value under the path or NullV

◆ Collect< T >()

IReadOnlyList<T> FaunaDB.Types.Value.Collect< T > ( Field< T >  field)

Loop through this node collecting the Field passed, assuming the node is an instance of ArrayV

See Field

Consider the Value node modeling the root of the tree:

{
"data": {
"arrayOfStrings": ["Jhon", "Bill"],
"arrayOfObjects": [ {"name": "Jhon"}, {"name": "Bill"} ]
}
}

The result tree can be accessed using:

node.Get("arrayOfStrings").Collect(Field.To<string>()); // ["Jhon", "Bill"]
Field<string> name = Field.At("name").To<string>();
node.Get("arrayOfObjects").Collect(name); // ["Jhon", "Bill"]
}
Parameters
fieldfield to extract from each array value
Returns
a IReadOnlyList<T> with the collected Field

◆ Get< T >()

T FaunaDB.Types.Value.Get< T > ( Field< T >  field)

Extract a Field from this node

See Field

Exceptions
InvalidOperationException
Parameters
fieldfield to extract
Returns
the resulting value of extracting the Field from this node

◆ GetOption< T >()

IOption<T> FaunaDB.Types.Value.GetOption< T > ( Field< T >  field)

Attempts to extact a Field from this node

See Field

Parameters
fieldfield to extract
Returns
An IOption<T> with the resulting value if the field's extraction was successful

◆ operator bool()

static FaunaDB.Types.Value.operator bool ( Value  v)
explicitstatic

◆ operator DateTime()

static FaunaDB.Types.Value.operator DateTime ( Value  v)
explicitstatic

◆ operator DateTimeOffset()

static FaunaDB.Types.Value.operator DateTimeOffset ( Value  v)
explicitstatic

◆ operator double()

static FaunaDB.Types.Value.operator double ( Value  v)
explicitstatic

◆ operator long()

static FaunaDB.Types.Value.operator long ( Value  v)
explicitstatic

◆ operator string()

static FaunaDB.Types.Value.operator string ( Value  v)
explicitstatic

◆ operator Value() [1/8]

static implicit FaunaDB.Types.Value.operator Value ( bool  b)
static

◆ operator Value() [2/8]

static implicit FaunaDB.Types.Value.operator Value ( byte[]  bytes)
static

◆ operator Value() [3/8]

static implicit FaunaDB.Types.Value.operator Value ( DateTime  dt)
static

◆ operator Value() [4/8]

static implicit FaunaDB.Types.Value.operator Value ( DateTimeOffset  dt)
static

◆ operator Value() [5/8]

static implicit FaunaDB.Types.Value.operator Value ( double  d)
static

◆ operator Value() [6/8]

static implicit FaunaDB.Types.Value.operator Value ( int  i)
static

◆ operator Value() [7/8]

static implicit FaunaDB.Types.Value.operator Value ( long  l)
static

◆ operator Value() [8/8]

static implicit FaunaDB.Types.Value.operator Value ( string  s)
static

◆ To< T >()

IResult<T> FaunaDB.Types.Value.To< T > ( )

Attempts to coerce this value to given type T specified.

Template Parameters
TThe type name in which this value shoulbe be decoded

The documentation for this class was generated from the following file: