Oihana PHP Arango

has.php

Table of Contents

Functions

has()  : string
Returns an AQL expression to test whether an attribute exists in a document.

Functions

has()

Returns an AQL expression to test whether an attribute exists in a document.

has(string $document, string $attributeName) : string

This helper wraps the ArangoDB AQL function HAS(document, attributeName) which returns true if the document has an attribute named attributeName, even if its value is falsy (null, 0, false, or empty string).

Example AQL usage:

HAS(doc, "name")              // returns true if doc has a "name" attribute
HAS(doc, "email")             // returns true if doc has an "email" attribute
HAS(doc, "nonExistent")       // returns false if attribute doesn't exist
Parameters
$document : string

The document variable or expression to test.

$attributeName : string

The attribute key to test for existence.

Tags
example
use function oihana\arango\db\functions\documents\has;

$expr = has('doc', 'name');
// Produces: 'HAS(doc, "name")'
see
https://docs.arangodb.com/stable/aql/functions/document-object/#has
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results