Length

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

Length( value )
Length( value )
length( value )
Length( value )

Description

The length function returns the number of characters in the provided string.

Although we mention characters, technically, we are talking about code points. In Unicode, a code point is usually, but not always, a character. Code points can sometimes represent single characters, but can also represent formatting and other non-alphanumeric characters.

For example, the character é can be the single character "e" that includes an acute accent (U+00E9), or it could be displayed as a single character but be composed of an "e" (U+0065) and a "combining" acute accent (U+0301). Visually, you cannot distinguish between the two.

Parameters

Parameter Type Definition and Requirements

value

String

The String that should have its characters counted.

Returns

An integer that reports the number of characters in the string.

Examples

result, err := client.Query(
	f.Arr{
		f.Length("fire"),
		f.Length("fire and fireman"),
		f.Length(""),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[4 16 0]
client.query(
  [
    q.Length('fire'),
    q.Length('fire and fireman'),
    q.Length(''),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ 4, 16, 0 ]
result = client.query(
  [
    q.length("fire"),
    q.length("fire and fireman"),
    q.length(""),
  ]
)
print(result)
[4, 16, 0]
[
  Length('fire'),
  Length('fire and fireman'),
  Length(''),
]
[ 4, 16, 0 ]
Query metrics:
  •    bytesIn:  63

  •   bytesOut:  21

  • 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!