StartsWith

StartsWith( value, search )
StartsWith( value, search )
StartsWith( value, search )
StartsWith( value, search )
starts_with( value, search )
StartsWith( value, search )

Description

The StartsWith function returns true when the value string starts with the search string, or false when it does not.

Parameters

Argument Type Definition and Requirements

value

The String to compare.

search

The String to search for at the start of value.

Returns

Returns a Boolean: true when value starts with search, or false when it does not.

Examples

The following query demonstrates the case where the value string starts with the search string:

try
{
    Value result = await client.Query(
        StartsWith("Fauna", "F")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
BooleanV(True)
result, err := client.Query(
	f.StartsWith("Fauna", "F"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
true
System.out.println(
    client.query(
        StartsWith("Fauna", "F")
    ).get()
);
true
client.query(
  q.StartsWith('Fauna', 'F')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
true
result = client.query(
  q.starts_with("Fauna", "F")
)
print(result)
True
try {
  println(Await.result(
  client.query(
    StartsWith("Fauna", "F")
  ),
  5.seconds
))} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
true

The following query demonstrates the case where the value string does not start with the search string:

try
{
    Value result = await client.Query(
        StartsWith("Fauna", "f")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
BooleanV(False)
result, err := client.Query(
	f.StartsWith("Fauna", "f"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
false
System.out.println(
    client.query(
        StartsWith("Fauna", "f")
    ).get()
);
false
client.query(
  q.StartsWith('Fauna', 'f')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
false
result = client.query(
  q.starts_with("Fauna", "f")
)
print(result)
False
try {
  println(Await.result(
  client.query(
    StartsWith("Fauna", "f")
  ),
  5.seconds
))} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
false

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!