And

And(value_1, value_2, ...)
And(value_1, value_2, ...)
And(value_1, value_2, ...)
And(value_1, value_2, ...)
and_(value_1, value_2, ...)
And(value_1, value_2, ...)

Description

The And function computes the conjunction of a list of boolean values, returning true if all elements are "true", and false otherwise.

Prior to version 3.0.0, all items in the value list were evaluated. With version 3.0.0, evaluation is short-circuited when a false value is encountered. For example, a collection is no longer created with this query:

And(false, CreateCollection({ name: "test" }))

Parameters

Argument Type Definition and Requirements

value

Boolean

One or more boolean values.

Returns

A boolean value.

Examples

The query below returns false because the last argument is "false".

client.Query(And(true, true, false));
false
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "and": [ true, true, false ] }'
HTTP/1.1 200 OK
{ "resource": false }
result, _ := client.Query(f.And(true, true, false))

fmt.Println(result)
false
System.out.println(
       client.query(And(Value(true), Value(true), Value(false)))
               .get());
false
client.query(q.And(true, true, false))
.then((ret) => console.log(ret))
false
client.query(q.and_(True, True, False))
false
client.query(And(true, true, false))
false

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!