-
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
feat: partitioned index #225
Conversation
lib/migrate.js
Outdated
* e.g. {fields: [{"foo": "asc"}, {"bar": "asc"}], partitioned: true} | ||
* @param {Function} cb | ||
*/ | ||
Cloudant.prototype.__createIndex = function(mo, model, name, indexObj, cb) { |
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.
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.
👍 renamed them to single _
31217ec
to
887a181
Compare
97f8fb0
to
60dff13
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.
I am not familiar with detailed implementation of Cloudant, but it makes sense to me high -level-ly 😄
}; | ||
|
||
/** | ||
* Perform the indexes comparison for `autoupdate`. |
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.
Is this function for comparing if indexes exist?
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.
@agnes512 yep, it returns the new indexes to add and old indexes to drop
test/partition.test.js
Outdated
}); | ||
}); | ||
|
||
it('configured true - create partitioned index for index entry', (done) => { |
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.
I feel like a test title like create partitioned index for index entry with partition enabled
would make the intention more clear. Same for configured false
test. ( Unless the option we enable/disable partitioned
called configured
)
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.
renamed all the tests title :)
index.def.fields[0]['prodName'].should.equal('desc'); | ||
index.def.fields[1][DEFAULT_MODEL_VIEW].should.equal('desc'); |
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.
I am not familiar with Cloudant index field. Why is this desc
and others are asc
?
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.
@agnes512 Good question, see https://github.com/strongloop/loopback-connector-cloudant/pull/225/files#diff-121c1d00e6380aa6109385e1df1ae803R66
The order code specified for prodName
is -1, which stands for desc
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.
looks like they need a better name 😆
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.
I mainly looked at the tests and had 2 comments.
@@ -37,7 +38,8 @@ async.waterfall([ | |||
setCloudantEnv, | |||
waitFor('/_all_dbs'), | |||
createAdmin(), | |||
createDB('test-db'), | |||
createDB(process.env.CLOUDANT_DATABASE), | |||
createPartitionedDB(process.env.CLOUDANT_PARTITIONED_DATABASE), |
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.
this doesn't seem to be called in other places?
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.
@jannyHou showed me where it's being used.
prodName: {type: String}, | ||
desc: {type: String}, | ||
}, { | ||
indexes: { |
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.
not really about this test case.. Do we have any tests to show after we've created a database using the partitioned:true
option, the indexes
look like this?
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.
Discussed it with @jannyHou. This test case is about if someone specify an indexes
for the product, it should be preserved after putting it into the database.
For the partitioned:true
"property", it is at the global level, so if we don't specify any indexes
, there will be no difference for the indexes between a partitioned database and a non-partitioned database.
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.
Discussed with @jannyHou about my comment and summarized in #225 (comment). It's looking good from the test perspective. so I trust the code is functional.
175ef0d
to
db8656e
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 #216
Support create partitioned index in partitioned database.
User can define the index in model config as
to create partitioned index.
If no
partitioned
property defined, the default index will be global.TODO:Related issues
Checklist
guide