Charming Robot
Charming Robot

Reputation: 2660

Array.contains in Firestore rules

How to use the JS native array.contains in Firestore rules?

function isCool() {
  return [
    'xxx',
    'yyy',
  ].contains(req.auth.uid)
}

The function above gives an error

Upvotes: 0

Views: 612

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50930

You are looking for in operator:

function isCool() {
  return request.auth.uid in ['xxx', 'yyy'];
}

It returns true if the value is present in the given list/array.

Upvotes: 6

Related Questions