public function truncate($collection)
    {
        $collectionId = $this->getCollectionId($collection);

        if ($this->isValidCollectionId($collectionId)) {
            throw new ClientException('Cannot alter a collection without a collection id');
        }

        $this->getConnection()->put(
            UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collectionId, self::OPTION_TRUNCATE]),
            ''
        );

        return true;
    }
public function truncate($collection)
    {
        $collectionId = $this->getCollectionId($collection);

        if ($this->isValidCollectionId($collectionId)) {
            throw new ClientException('Cannot alter a collection without a collection id');
        }

        $this->getConnection()->put(
            UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collectionId, self::OPTION_TRUNCATE]),
            ''
        );

        return true;
    }
public function truncate ( $ collection ) { $ collectionId = $ this -> getCollectionId ( $ collection ) ; if ( $ this -> isValidCollectionId ( $ collectionId ) ) { throw new ClientException ( 'Cannot alter a collection without a collection id' ) ; } $ this -> getConnection ( ) -> put ( UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collectionId , self :: OPTION_TRUNCATE ] ) , '' ) ; return true ; }
Truncate a collection

This will remove all documents from the collection but will leave the metadata and indexes intact.

@throws Exception

@param mixed $collection - collection id as string or number or collection object

@return bool - always true, will throw if there is an error
Truncate a collection