cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

Query index in couchdb and support dict syntax: _id in database #369

Closed tiangolo closed 6 years ago

tiangolo commented 6 years ago

What

I added 2 things, I needed both of them at the same time so I ended up doing a single PR instead of 2, sorry for that.

_id = 'julia30'
doc_exists = _id in my_database

if doc_exists:
    print('doc with _id julia30 exists in DB')

How

Testing

Create a CouchDatabase object and call the create_query_index the same way you would for a Cloudant database.

Issues

I didn't create an issue before solving it.

tiangolo commented 6 years ago

Thanks for the review @emlaver

About setting CouchDB to the latest Docker image, I don't see any documentation on how to specify the version of CouchDB in Travis using simple, standard Travis with services: https://docs.travis-ci.com/user/database-setup/#CouchDB


I know it could be quite simpler to with Docker.

And I see there are branch names in this repo related to migrating the tests to Docker.

Do you need help with some of that? I have "some" experience with Docker, but I don't want to do stuff that doesn't align with the plans of the team.

For example, this project is configured to run tests for a full app in Docker. And run them on Travis (and GitLab CI, etc. It's quite simple to change the CI system once it's all in Docker).

emlaver commented 6 years ago

@tiangolo I'm currently working in a branch to use Docker to run our tests against the 2.1.1 version. I'll open a PR and our team with review when it's ready.

tiangolo commented 6 years ago

Excellent, thanks for reporting back @emlaver .

BTW, I'm actually running my local tests against a Docker (Docker Compose) CouchDB. Please let me know if there's anything I can help with that.

And let me know if there's anything still missing here (in this PR) that should be fixed before your PR is ready (I already added the missing tests).

emlaver commented 6 years ago

@tiangolo I've merged the CouchDB 2.1.1 testing PR. Please rebase your PR.

tiangolo commented 6 years ago

Thanks @emlaver , that's great! :tada:

Done, rebased (also fixed an issue I had there) :heavy_check_mark:

tiangolo commented 6 years ago

Hi @emlaver , do you have any news about this? :grin:

tiangolo commented 6 years ago

Thanks @emlaver , done :white_check_mark:

tiangolo commented 6 years ago

:tada: Thanks!

emlaver commented 6 years ago

@tiangolo Thank you for your work!