Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#6020) - separate mapreduce into mapreduce & abstract-mapreduce #6165

Merged
merged 2 commits into from Jan 25, 2017

Conversation

@nolanlawson
Copy link
Member

commented Jan 21, 2017

This is step 1 in fixing #6020, i.e. moving pouchdb-find into core.

This breaks pouchdb-mapreduce into two modules: pouchdb-mapreduce and pouchdb-abstract-mapreduce. This will make it compatible with pouchdb-find (which uses pouchdb-abstract-mapreduce under the hood) and therefore we can move it into core and allow pouchdb-find and pouchdb-mapreduce to share the same core implementation.

The idea was laid out a long time ago in pouchdb/mapreduce#250, but basically the delegation of responsibilities is:

  • pouchdb-abstract-mapreduce: contains core secondary index logic, including handling of startkey/endkey/etc., building the index itself, managing the _local/mrviews document, registering dependent dbs, etc.
  • pouchdb-mapreduce contains all the map/reduce-specific logic, such as evaling map/reduce functions.
  • pouchdb-find contains the Mango-specific logic, such as how to build a "map-like" function based on a query definition (fields, sort, etc.).

Both pouchdb-mapreduce and pouchdb-find depend on pouchdb-abstract-mapreduce. There is no eval() in pouchdb-abstract-mapreduce, meaning pouchdb-find allows us to do secondary indexes without any arbitrary code execution.

@@ -1,21 +1,20 @@
pouchdb

This comment has been minimized.

Copy link
@nolanlawson

nolanlawson Jan 21, 2017

Author Member

this README accidentally had a lot of typos in it. I corrected it as part of this PR.

@@ -1,19 +1,20 @@
pouchdb-mapreduce-utils ![semver non-compliant](https://img.shields.io/badge/semver-non--compliant-red.svg)

This comment has been minimized.

Copy link
@nolanlawson

nolanlawson Jan 21, 2017

Author Member

this readme also had a bunch of typos

QueryParseError,
NotFoundError,
BuiltInError
} from './errors';

This comment has been minimized.

Copy link
@nolanlawson

nolanlawson Jan 21, 2017

Author Member

I moved these error objects into pouchdb-mapreduce-utils because they are needed by both pouchdb-mapreduce and pouchdb-abstract-mapreduce.

@nolanlawson nolanlawson force-pushed the abstract-mapreduce branch from d22db6f to e7293dc Jan 22, 2017

};
return db.post(doc).then(function () {
return db.query('barbar/scores', {key: 'bar'});
}).should.be.rejected;

This comment has been minimized.

Copy link
@willholley

willholley Jan 23, 2017

Member

This looks like it would incorrectly pass if db.post() failed (e.g. if we add validation to reject invalid design docs similar to CouchDB). Should the test be more explicit about which promise is rejected?

This comment has been minimized.

Copy link
@nolanlawson

nolanlawson Jan 23, 2017

Author Member

Yes, you're right. I'll update it and the other one I copypasted from.

@nolanlawson nolanlawson merged commit 1f6debc into master Jan 25, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 100.0%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.