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:

Value result = await client.Query(
  StartsWith("Fauna", "F")
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
result, err := client.Query(
  f.StartsWith("Fauna", "F"))

if (err != nil) {
  fmt.Println(err)
} else {
  fmt.Println(result)
}
System.out.println(
    client.query(
        StartsWith("Fauna", "F")
    ).get()
);
client.query(
  q.StartsWith('Fauna', 'F')
)
.then((ret) => console.log(ret))
print(client.query(
  q.starts_with("Fauna", "F")
))
println(Await.result(
  client.query(
    StartsWith("Fauna", "F"),
  ),
  5.seconds
))
BooleanV(True)
true
true
true
True
true

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

Value result = await client.Query(
  StartsWith("Fauna", "f")
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
result, err := client.Query(
  f.StartsWith("Fauna", "f"))

if (err != nil) {
  fmt.Println(err)
} else {
  fmt.Println(result)
}
System.out.println(
    client.query(
        StartsWith("Fauna", "f")
    ).get()
);
client.query(
  q.StartsWith('Fauna', 'f')
)
.then((ret) => console.log(ret))
print(client.query(
  q.starts_with("Fauna", "f")
))
println(Await.result(
  client.query(
    StartsWith("Fauna", "f"),
  ),
  5.seconds
))
BooleanV(False)
false
false
false
False
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!