-
Notifications
You must be signed in to change notification settings - Fork 21
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
Partition field #230
Partition field #230
Conversation
acc6cd0
to
b0e1c05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of the partitionKey feature! I left a few comments.
}); | ||
resultTaggedFood.length.should.equal(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't it equal to 3?
(err, results) => { | ||
if (err) return done(err); | ||
should.exist(results); | ||
results.length.should.equal(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't it equal to 3? and what's the difference between find all records by partition key from option
and find all records by partition key from property
? Does it mean we can invoke the partition key from property or option, and they they give the same result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the tests are confusing, let me add more docs for it.
{partitionKey: 'london'}, (err, results) => { | ||
if (err) return done(err); | ||
should.exist(results); | ||
results.length.should.equal(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the options overrides the query clause?
And if it does, why isn't it result to 2? ( food
and london
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the options overrides the query clause?
Yes, it's 0 because when search within partition london
, there is no record with city
as toronto
. See the sample records created in https://github.com/strongloop/loopback-connector-cloudant/pull/230/files#diff-121c1d00e6380aa6109385e1df1ae803R237
fbbabd0
to
b522a12
Compare
Cloudant.prototype._getPartitionKey = function(mo, query, options) { | ||
const pkFromOption = options && options.partitionKey; | ||
debug('_getPartitionKey pkFromOption %s', pkFromOption); | ||
if (pkFromOption) return pkFromOption; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if option has partitionKey, return immediately.
b522a12
to
7c54de8
Compare
test/partition.test.js
Outdated
@@ -223,6 +229,10 @@ describe('cloudant - partitioned db', () => { | |||
}); | |||
|
|||
it('partition key in options overrides property for find all', (done) => { | |||
// Find records with partition `toronto`, tag `food`, city `toronto`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with partition toronto
-> with partition london
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch !
@@ -235,11 +245,18 @@ describe('cloudant - partitioned db', () => { | |||
}); | |||
|
|||
const SEED_DATA = [ | |||
// partition `toronto`, tag `drink` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 the comments are helpful
7c54de8
to
f2050d6
Compare
f2050d6
to
f72bbea
Compare
* chore: update copyright year (Agnes Lin) * replace couchdb3 docker img with a stable version (Agnes Lin) * docs: add partition document (#232) (Janny) * fixup!: fix the dependency version (#233) (Janny) * feat: query with partition field (#230) (Janny) * chore: improve issue and PR templates (Nora) * feat: add partitioned find (#229) (Janny) * add docker setup script (#227) (Janny) * feat: partitioned index (#225) (Janny) * fix CODEOWNERS file (Diana Lau) * update docker image (#224) (Janny)
Description
connect to #217
PR loopbackio/loopback-connector-couchdb2#72 adds the name of partition key field to couchdb/cloudant's model object.
When the partition key field is included in query,
Cloudant.prototype.all
will trigger parititonFind from driver instead of a global search.The partition key provided in
options
will override the one in query.Related issues
Checklist
guide