StartsWith

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

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

Parameter Type Definition and Requirements

value

String

The String to compare.

search

String

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:

result, err := client.Query(
	f.StartsWith("Fauna", "F"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
true
client.query(
  q.StartsWith('Fauna', 'F')
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
true
result = client.query(
  q.starts_with("Fauna", "F")
)
print(result)
True
StartsWith('Fauna', 'F')
true
Query metrics:
  •    bytesIn:  35

  •   bytesOut:  17

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    retries:   0

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

result, err := client.Query(
	f.StartsWith("Fauna", "f"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
false
client.query(
  q.StartsWith('Fauna', 'f')
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
false
result = client.query(
  q.starts_with("Fauna", "f")
)
print(result)
False
StartsWith('Fauna', 'f')
false
Query metrics:
  •    bytesIn:  35

  •   bytesOut:  18

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 3ms

  •    retries:   0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!