Firestore/src/Query.php
public function select(array $fieldPaths)
    {
        $fields = [];
        foreach ($fieldPaths as $field) {
            if (!($field instanceof FieldPath)) {
                $field = FieldPath::fromString($field);
            }

            $fields[] = [
                'fieldPath' => $field->pathString()
            ];
        }

        if (!$fields) {
            $fields[] = [
                'fieldPath' => self::DOCUMENT_ID
            ];
        }

        return $this->newQuery([
            'select' => [
                'fields' => $fields
            ]
        ], true);
    }
public function select(array $fieldPaths)
    {
        $fields = [];
        foreach ($fieldPaths as $field) {
            if (!($field instanceof FieldPath)) {
                $field = FieldPath::fromString($field);
            }

            $fields[] = [
                'fieldPath' => $field->pathString()
            ];
        }

        if (!$fields) {
            $fields[] = [
                'fieldPath' => self::DOCUMENT_ID
            ];
        }

        return $this->newQuery([
            'select' => [
                'fields' => $fields
            ]
        ], true);
    }
public function select ( array $ fieldPaths ) { $ fields = [ ] ; foreach ( $ fieldPaths as $ field ) { if ( ! ( $ field instanceof FieldPath ) ) { $ field = FieldPath :: fromString ( $ field ) ; } $ fields [ ] = [ 'fieldPath' => $ field -> pathString ( ) ] ; } if ( ! $ fields ) { $ fields [ ] = [ 'fieldPath' => self :: DOCUMENT_ID ] ; } return $ this -> newQuery ( [ 'select' => [ 'fields' => $ fields ] ] , true ) ; }
Add a SELECT to the Query.

Creates and returns a new Query instance that applies a field mask to the
result and returns only the specified subset of fields. You can specify a
list of field paths to return, or use an empty list to only return the
references of matching documents.

Subsequent calls to this method will override previous values.

Example:
```
$query = $query->select(['firstName']);
```

@param string[]|FieldPath[] $fieldPaths The projection to return, in the
form of an array of field paths. To only return the name of the
document, provide an empty array.
@return Query A new instance of Query with the given changes applied.
Add a SELECT to the Query .