using System;
namespace Firebase.Database.Query
{
///
/// Query extensions providing linq like syntax for firebase server methods.
///
public static class QueryFactoryExtensions
{
///
/// Adds an auth parameter to the query.
///
/// The child.
/// The auth token.
/// The .
internal static AuthQuery WithAuth(this FirebaseQuery node, Func tokenFactory)
{
return new AuthQuery(node, tokenFactory, node.Client);
}
///
/// References a sub child of the existing node.
///
/// The child.
/// The path of sub child.
/// The .
public static ChildQuery Child(this ChildQuery node, Func pathFactory)
{
return new ChildQuery(node, pathFactory, node.Client);
}
///
/// Order data by given . Note that this is used mainly for following filtering
/// queries and due to firebase implementation
/// the data may actually not be ordered.
///
/// The child.
/// The property name.
/// The .
public static OrderQuery OrderBy(this ChildQuery child, Func propertyNameFactory)
{
return new OrderQuery(child, propertyNameFactory, child.Client);
}
///
/// Order data by $key. Note that this is used mainly for following filtering queries and due to firebase
/// implementation
/// the data may actually not be ordered.
///
/// The child.
/// The .
public static OrderQuery OrderByKey(this ChildQuery child)
{
return child.OrderBy("$key");
}
///
/// Order data by $value. Note that this is used mainly for following filtering queries and due to firebase
/// implementation
/// the data may actually not be ordered.
///
/// The child.
/// The .
public static OrderQuery OrderByValue(this ChildQuery child)
{
return child.OrderBy("$value");
}
///
/// Order data by $priority. Note that this is used mainly for following filtering queries and due to firebase
/// implementation
/// the data may actually not be ordered.
///
/// The child.
/// The .
public static OrderQuery OrderByPriority(this ChildQuery child)
{
return child.OrderBy("$priority");
}
///
/// Instructs firebase to send data greater or equal to the . This must be preceded by an
/// OrderBy query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery StartAt(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "startAt", valueFactory, child.Client);
}
///
/// Instructs firebase to send data lower or equal to the . This must be preceded by an
/// OrderBy query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery EndAt(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "endAt", valueFactory, child.Client);
}
///
/// Instructs firebase to send data equal to the . This must be preceded by an OrderBy
/// query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
///
/// Instructs firebase to send data greater or equal to the . This must be preceded by an
/// OrderBy query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery StartAt(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "startAt", valueFactory, child.Client);
}
///
/// Instructs firebase to send data lower or equal to the . This must be preceded by an
/// OrderBy query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery EndAt(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "endAt", valueFactory, child.Client);
}
///
/// Instructs firebase to send data equal to the . This must be preceded by an OrderBy
/// query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
///
/// Instructs firebase to send data equal to the . This must be preceded by an OrderBy
/// query.
///
/// Current node.
/// Value to start at.
/// The .
public static FilterQuery EqualTo(this ParameterQuery child, Func valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
///
/// Limits the result to first items.
///
/// Current node.
/// Number of elements.
/// The .
public static FilterQuery LimitToFirst(this ParameterQuery child, Func countFactory)
{
return new FilterQuery(child, () => "limitToFirst", () => countFactory(), child.Client);
}
///
/// Limits the result to last items.
///
/// Current node.
/// Number of elements.
/// The .
public static FilterQuery LimitToLast(this ParameterQuery child, Func countFactory)
{
return new FilterQuery(child, () => "limitToLast", () => countFactory(), child.Client);
}
}
}