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

Compose the _id for a document in a partition database #218

Closed
2 tasks
jannyHou opened this issue Oct 7, 2019 · 3 comments
Closed
2 tasks

Compose the _id for a document in a partition database #218

jannyHou opened this issue Oct 7, 2019 · 3 comments
Labels

Comments

@jannyHou
Copy link
Contributor

jannyHou commented Oct 7, 2019

See parent story #214

For a non-partitioned db, db.insert() will give the document a random string as _id if it’s missing in the payload. While for partitioned database, _id is a must provide field, the random string need to be generated using 'uuid/v4', see some examples in the driver repo. Let's figure out a better UX for users to provide the id part.

Considering when inserting document into a partitioned db, people MUST provide value for _id with partitionKey specified, let's either

  • honour the full value of _id from model's id field (invalid value will be rejected by Cloudant service)
    or
  • if the model contains a property marked as partitionKey:
    • if id is in pattern <partitionKey>: id, use the full value
    • otherwise compose the id field and partitionKey field as <partitionKey>: id

Acceptance Criteria

  • Improve the create() method to handle the _id composition in a partitioned database

    • honour the full value of _id from model's id field (invalid value will be rejected by Cloudant service)
      or
    • if the model contains a property marked as partitionKey:
      • if id is in pattern <partitionKey>: id, use the full value
      • otherwise compose the id field and partitionKey field as <partitionKey>: id
  • Developers can config the partition key property follows:

    customers = db.define('customers', {
    userId: {type: Number, id: true},
    countryCode: {type: String, isPartitionKey: true},
    name: String,
    zipCode: Number,

});

@dhmlau dhmlau added 2020Q1 and removed 2019Q4 p2 labels Oct 9, 2019
@emonddr emonddr changed the title Improve create() method to handle missing _id in a partitioned db Compose the _id for a document in a partition database Oct 10, 2019
@dhmlau dhmlau removed the 2020Q1 label Nov 22, 2019
@stale
Copy link

stale bot commented Jan 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 21, 2020
@jannyHou jannyHou removed the stale label Jan 21, 2020
@stale
Copy link

stale bot commented Mar 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 21, 2020
@stale
Copy link

stale bot commented Apr 4, 2020

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants