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

[Cosmos] Item Create/Update/Delete #1811

Open
analogrelay opened this issue Sep 18, 2024 · 0 comments
Open

[Cosmos] Item Create/Update/Delete #1811

analogrelay opened this issue Sep 18, 2024 · 0 comments
Assignees
Labels
Cosmos The azure_cosmos crate

Comments

@analogrelay
Copy link
Member

#1809 will add querying for Cosmos Items. We need to add the ability to create/update/delete items. The API would be something like this, based on the Go SDK:

pub trait ContainerClientMethods {
    // ... other methods ...
    // Will fail if an item with the same ID already exists (POST with Upsert header false)
    fn create_item(&self, partition_key: impl Into<PartitionKey>, item: impl Serialize, options: Option<CreateItemOptions>);
    // Will replace an item with the same ID if one exists (POST with Upsert header true)
    fn upsert_item(&self, partition_key: impl Into<PartitionKey>, item: impl Serialize, options: Option<UpsertItemOptions>);
    // Will fail if an item with the same ID does NOT exist (PUT)
    fn replace_item(&self, partition_key: impl Into<PartitionKey>, item: impl Serialize, options: Option<ReplaceItemOptions>);
    // Will fail if an item with the specified ID does not exist (DELETE)
    fn delete_item(&self, partition_key: impl Into<PartitionKey>, item_id: impl Into<String>, options: Option<DeleteItemOptions>);
}

Notable exclusions: PATCHing documents (requires modelling the patch operations and will be handled separately)

Open Questions:

  • Does each operation need it's own options? The Go SDK uses a single shared ItemOptions. We can do the same, but if we ever need operation-specific options, it's a breaking change. I'll check if the other SDKs generally accept that risk and use a shared options type. If they do, I think we can here as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cosmos The azure_cosmos crate
Projects
None yet
Development

No branches or pull requests

1 participant