IsDatabase

Copied!
( value )

Description

The IsDatabase function returns true only if value is a database document, otherwise it returns false.

Parameters

Parameter Type Definition and Requirements

value

Any

Any value, which is to be tested to determine whether it is a database document or not.

Returns

Returns a Boolean, indicating whether value was a database document 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 IsDatabase with that value:

Copied!
(
  [
    ['array'],
    true,
    false,
    new Uint8Array([1, 2, 3, 4]),
    [0x1, 0x2, 0x3, 0x4],
    ('Letters'),
    ('credentials/self'),
    ('child_db'),
    ('2019-11-12'),
    (('Letters'), 123),
    10.1,
    ('double'),
    ('letters'),
    10,
    ((), '1'),
    (('x', ('x'))),
    null,
    { x: 10 },
    ('employees'),
    (('letters')),
    'ten',
    '10',
    ('2020-07-06T12:34:56.789Z'),
    ((), '1'),
  ],
  ('x', {
    value: ('x'),
    IsDatabase: (('x')),
  })
)
[
  { value: [ 'array' ], IsDatabase: false },
  { value: true, IsDatabase: false },
  { value: false, IsDatabase: false },
  { value: { '0': 1, '1': 2, '2': 3, '3': 4 }, IsDatabase: false },
  { value: [ 1, 2, 3, 4 ], IsDatabase: false },
  { value: ("Letters"), IsDatabase: false },
  {
    value: ((), "302043979982045696"),
    IsDatabase: false
  },
  { value: ("child_db"), IsDatabase: true },
  { value: ("2019-11-12"), IsDatabase: false },
  { value: (("Letters"), "123"), IsDatabase: false },
  { value: 10.1, IsDatabase: false },
  { value: ("double"), IsDatabase: false },
  { value: ("letters"), IsDatabase: false },
  { value: 10, IsDatabase: false },
  { value: ((), "1"), IsDatabase: false },
  { value: (("x", ("x"))), IsDatabase: false },
  { value: null, IsDatabase: false },
  { value: { x: 10 }, IsDatabase: false },
  { value: ("employees"), IsDatabase: false },
  { value: (("letters")), IsDatabase: false },
  { value: 'ten', IsDatabase: false },
  { value: '10', IsDatabase: false },
  { value: ("2020-07-06T12:34:56.789Z"), IsDatabase: false },
  { value: ((), "1"), IsDatabase: false }
]
Query metrics:
  •    bytesIn:   604

  •   bytesOut: 1,631

  • computeOps:     2

  •    readOps:     0

  •   writeOps:     0

  •  readBytes:   373

  • writeBytes:     0

  •  queryTime:  21ms

  •    retries:     0

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 Login function (not shown here), so that Ref("credentials/self") returns a valid value.

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!