Skip to content

Add support for Mango queries - #20

Merged
1999 merged 2 commits into
1999:masterfrom
Flamenco:feature_mango
Feb 4, 2017
Merged

Add support for Mango queries#20
1999 merged 2 commits into
1999:masterfrom
Flamenco:feature_mango

Conversation

@Flamenco

@Flamenco Flamenco commented Jan 1, 2017

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread test/test.js
'useCache',
'listDatabases', 'createDatabase', 'dropDatabase',
'insert', 'update', 'del', 'get',
'insert', 'update', 'del', 'get', 'mango',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I would say that there's not enough testing for this new feature. Could you please add some more tests? And I also think that this mango() method should throw if couchdb version is less than 2. What do you think about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it should just forward whatever the database returns for the request. So the promise returned will reject, yes?

I didn't add tests because I was not sure what version you were running the tests against, but shouldn't be a problem if your CI is using 2.0. Is it?

I've been using this in production for a couple of weeks and it's really nice.

I also added a method for _changes and that's been really sweet, but required a bit of plumbing to implement the streaming. Was waiting on this one before proceeding with that PR.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think it should just forward whatever the database returns for the request. So the promise returned will reject, yes?

In this case behaviour for CouchDB@1 and CouchDB@2 will be different (couchdb@2 will return smth and couchdb@1 will reject with 404), right? I think it would be better if node-couchdb returns some kind of special error (EOLDSERVER for instance) in this case instead of letting user guess what happened based on 404 server response status code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Either way, because both Couch versions have well documented the response, maybe it's best to not try to wrap one error in another. This would DRY up the documentation, and be more maintainable.

Another approach would be to maintain a list of v2 functions and do as you suggest, throw a version error.

Let me know your thoughts and I will update the PR.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Your current PR is better than what I suggested. No changes are needed here for tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we can add version checking in another PR. OK?

Comment thread lib/node-couchdb.js
* - resolved with {data, headers, status} object
* - rejected with `request` original error
*
* @param {String} dbName database name

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

String|Object would be better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread package.json
{
"name": "node-couchdb",
"version": "1.1.0",
"version": "1.1.1",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Better remove this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread test/test.js
'useCache',
'listDatabases', 'createDatabase', 'dropDatabase',
'insert', 'update', 'del', 'get',
'insert', 'update', 'del', 'get', 'mango',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Your current PR is better than what I suggested. No changes are needed here for tests.

@1999

1999 commented Jan 28, 2017

Copy link
Copy Markdown
Owner

@Flamenco could you please add the changes I ask for?

@Flamenco

Copy link
Copy Markdown
Contributor Author

I should have something in the next day or two. I added a bunch of changes for streaming the _changes endpoint and they are in my same branch. I need to refactor them into a separate PR.

@Flamenco

Flamenco commented Feb 1, 2017

Copy link
Copy Markdown
Contributor Author

OK, I updated comment and will add my other PRs in a separate feature branch.

Comment thread test/test.js
'useCache',
'listDatabases', 'createDatabase', 'dropDatabase',
'insert', 'update', 'del', 'get',
'insert', 'update', 'del', 'get', 'mango',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did you want me to remove 'insert', 'update', 'del', 'get', 'mango', <----- ?

Not sure if:

Your current PR is better than what I suggested. No changes are needed here for tests

applied to that line or just in general....

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In general :)

@1999 1999 mentioned this pull request Feb 4, 2017
@1999
1999 merged commit d04c848 into 1999:master Feb 4, 2017
@Flamenco
Flamenco deleted the feature_mango branch February 6, 2017 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants