FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
IsKey
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
IsKey( value )
is_key( value )
IsKey( value )
IsKey( value )
IsKey( value )
Description
The IsKey
function returns true
only if value
is a
key, otherwise it returns false
.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Any |
Any value, which is to be tested to determine whether it is a key or not. |
Returns
Returns a Boolean, indicating whether value
was a
key or not.
Examples
The following query uses Map
to iterate over an array of all of
the types of values that can be tested by a type-check function, passing
each item into a Lambda
function that returns an object, which
contains the value and the result of calling IsKey
with that
value:
[
{ value: [ 'array' ], IsKey: false },
{ value: true, IsKey: false },
{ value: false, IsKey: false },
{ value: Bytes("AQIDBA=="), IsKey: false },
{ value: [ 1, 2, 3, 4 ], IsKey: false },
{ value: Collection("Letters"), IsKey: false },
{ value: Ref(Credentials(), "268432612451680768"), IsKey: false },
{ value: Database("child_db"), IsKey: false },
{ value: Date("2019-11-12"), IsKey: false },
{ value: Ref(Collection("Letters"), "123"), IsKey: false },
{ value: 10.1, IsKey: false },
{ value: Function("double"), IsKey: false },
{ value: Index("letters"), IsKey: false },
{ value: 10, IsKey: false },
{ value: Ref(Keys(), "1"), IsKey: true },
{ value: Query(Lambda("x", Var("x"))), IsKey: false },
{ value: null, IsKey: false },
{ value: { x: 10 }, IsKey: false },
{ value: Role("employees"), IsKey: false },
{ value: Match(Index("letters")), IsKey: false },
{ value: 'ten', IsKey: false },
{ value: '10', IsKey: false },
{ value: Time("2020-06-15T21:22:19.397Z"), IsKey: false },
{ value: Ref(Tokens(), "1"), IsKey: false }
]
[{'value': ['array'], 'IsKey': False}, {'value': True, 'IsKey': False}, {'value': False, 'IsKey': False}, {'value': bytearray(b'\x01\x02\x03\x04'), 'IsKey': False}, {'value': [1, 2, 3, 4], 'IsKey': False}, {'value': Ref(id=Letters, collection=Ref(id=collections)), 'IsKey': False}, {'value': Ref(id=282032258185953792, collection=Ref(id=credentials)), 'IsKey': False}, {'value': Ref(id=child_db, collection=Ref(id=databases)), 'IsKey': False}, {'value': datetime.date(2019, 11, 12), 'IsKey': False}, {'value': Ref(id=123, collection=Ref(id=Letters, collection=Ref(id=collections))), 'IsKey': False}, {'value': 10.1, 'IsKey': False}, {'value': Ref(id=double, collection=Ref(id=functions)), 'IsKey': False}, {'value': Ref(id=letters, collection=Ref(id=indexes)), 'IsKey': False}, {'value': 10, 'IsKey': False}, {'value': Ref(id=1, collection=Ref(id=keys)), 'IsKey': True}, {'value': Query({'api_version': '4', 'lambda': 'x', 'expr': {'var': 'x'}}), 'IsKey': False}, {'value': None, 'IsKey': False}, {'value': {'x': 10}, 'IsKey': False}, {'value': Ref(id=employees, collection=Ref(id=roles)), 'IsKey': False}, {'value': SetRef({'match': Ref(id=letters, collection=Ref(id=indexes))}), 'IsKey': False}, {'value': 'ten', 'IsKey': False}, {'value': '10', 'IsKey': False}, {'value': FaunaTime('2020-07-06T12:34:56.789Z'), 'IsKey': False}, {'value': Ref(id=1, collection=Ref(id=tokens)), 'IsKey': False}]
[map[IsKey:false value:[array]] map[IsKey:false value:true] map[IsKey:false value:false] map[IsKey:false value:[1 2 3 4]] map[IsKey:false value:[1 2 3 4]] map[IsKey:false value:{Letters 0xc00008ffb0 0xc00008ffb0 <nil>}] map[IsKey:false value:{280481857410171392 0xc00012e0f0 0xc00012e0f0 <nil>}] map[IsKey:false value:{child_db 0xc00012e210 0xc00012e210 <nil>}] map[IsKey:false value:{0 63709113600 <nil>}] map[IsKey:false value:{123 0xc000148150 0xc000148150 <nil>}] map[IsKey:false value:10.1] map[IsKey:false value:{double 0xc0001482a0 0xc0001482a0 <nil>}] map[IsKey:false value:{letters 0xc0001483c0 0xc0001483c0 <nil>}] map[IsKey:false value:10] map[IsKey:true value:{1 0xc000148510 0xc000148510 <nil>}] map[IsKey:false value:{[123 34 97 112 105 95 118 101 114 115 105 111 110 34 58 34 51 34 44 34 108 97 109 98 100 97 34 58 34 120 34 44 34 101 120 112 114 34 58 123 34 118 97 114 34 58 34 120 34 125 125]}] map[IsKey:false value:{}] map[IsKey:false value:{}] map[IsKey:false value:map[x:10]] map[IsKey:false value:{employees 0xc000148720 0xc000148720 <nil>}] map[IsKey:false value:{map[match:{letters 0xc000148870 0xc000148870 <nil>}]}] map[IsKey:false value:ten] map[IsKey:false value:10] map[IsKey:false value:{789000000 63729635696 <nil>}] map[IsKey:false value:{1 0xc000148a20 0xc000148a20 <nil>}]]
Arr(ObjectV(value: Arr(StringV(array)),IsKey: BooleanV(False)), ObjectV(value: BooleanV(True),IsKey: BooleanV(False)), ObjectV(value: BooleanV(False),IsKey: BooleanV(False)), ObjectV(value: BytesV(0x01, 0x02, 0x03, 0x04),IsKey: BooleanV(False)), ObjectV(value: Arr(LongV(1), LongV(2), LongV(3), LongV(4)),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "Letters", collection = RefV(id = "collections")),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "295432898045018624", collection = RefV(id = "credentials")),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "child_db", collection = RefV(id = "databases")),IsKey: BooleanV(False)), ObjectV(value: FaunaDate(2019-11-12 12:00:00 AM),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "123", collection = RefV(id = "Letters", collection = RefV(id = "collections"))),IsKey: BooleanV(False)), ObjectV(value: DoubleV(10.1),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "double", collection = RefV(id = "functions")),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "letters", collection = RefV(id = "indexes")),IsKey: BooleanV(False)), ObjectV(value: LongV(10),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "1", collection = RefV(id = "keys")),IsKey: BooleanV(True)), ObjectV(value: QueryV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Query.Expr]),IsKey: BooleanV(False)), ObjectV(value: NullV,IsKey: BooleanV(False)), ObjectV(value: ObjectV(x: LongV(10)),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "employees", collection = RefV(id = "roles")),IsKey: BooleanV(False)), ObjectV(value: SetRefV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Types.Value]),IsKey: BooleanV(False)), ObjectV(value: StringV(ten),IsKey: BooleanV(False)), ObjectV(value: StringV(10),IsKey: BooleanV(False)), ObjectV(value: FaunaTime(2020-07-06T12:34:56.789Z),IsKey: BooleanV(False)), ObjectV(value: RefV(id = "1", collection = RefV(id = "tokens")),IsKey: BooleanV(False)))
[
{ value: [ 'array' ], IsKey: false },
{ value: true, IsKey: false },
{ value: false, IsKey: false },
{ value: { '0': 1, '1': 2, '2': 3, '3': 4 }, IsKey: false },
{ value: [ 1, 2, 3, 4 ], IsKey: false },
{ value: Collection("Letters"), IsKey: false },
{ value: Ref(Credentials(), "302043979982045696"), IsKey: false },
{ value: Database("child_db"), IsKey: false },
{ value: Date("2019-11-12"), IsKey: false },
{ value: Ref(Collection("Letters"), "123"), IsKey: false },
{ value: 10.1, IsKey: false },
{ value: Function("double"), IsKey: false },
{ value: Index("letters"), IsKey: false },
{ value: 10, IsKey: false },
{ value: Ref(Keys(), "1"), IsKey: true },
{ value: Query(Lambda("x", Var("x"))), IsKey: false },
{ value: null, IsKey: false },
{ value: { x: 10 }, IsKey: false },
{ value: Role("employees"), IsKey: false },
{ value: Match(Index("letters")), IsKey: false },
{ value: 'ten', IsKey: false },
{ value: '10', IsKey: false },
{ value: Time("2020-07-06T12:34:56.789Z"), IsKey: false },
{ value: Ref(Tokens(), "1"), IsKey: false }
]
This query operates on a pre-existing schema, which is not provided here. Also, the query is executed via a client connection, that uses a secret
acquired by calling the |
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!