Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Add method bulkGet #91

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/Doctrine/CouchDB/CouchDBClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,29 @@ public function ensureFullCommit()
throw HTTPException::fromResponse($path, $response);
}

return $response->body;
}

/**
* Bulk get.
*
* @param array $docs
sidneycorreia marked this conversation as resolved.
Show resolved Hide resolved
*
* @throws HTTPException
*
* @return array
Copy link
Member

@greg0ire greg0ire Jan 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of the response is an array? What type are the elements in the array exactly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your link is broken

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so it should also be

Suggested change
* @return array
* @return array<int, array<string, string>>

correct?

*/
public function bulkGet(array $docs = [])
Copy link
Member

@greg0ire greg0ire Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a return type declaration here?

Copy link
Author

@sidneycorreia sidneycorreia Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this return type is too complex for method documentation. We can add a link to method's official documentation http://docs.couchdb.org/en/2.2.0/api/database/bulk-api.html#db-bulk-get

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it return other PHP types than array like the previous return annotation suggests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting this

Suggested change
public function bulkGet(array $docs = [])
public function bulkGet(array $docs = []): array

{
$path = '/'.$this->databaseName.'/_bulk_get';

$response = $this->httpClient->request('POST', $path, json_encode(['docs' => $docs]));
sidneycorreia marked this conversation as resolved.
Show resolved Hide resolved

if ($response->status != 200) {
throw HTTPException::fromResponse($path, $response);
}


return $response->body;
}
}