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

types(update): wrap metadata param in Partial #199

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

omikader
Copy link
Contributor

@omikader omikader commented Jan 31, 2024

Problem

This PR makes it so that you don't need to supply all of the required fields in your custom metadata interface when updating a vector using the TS client.

For example, say I have a metadata interface defined as the following:

interface MyMetadata {
  title: string;
  source: string;
  isArchived?: boolean;
}

I want to update the value for isArchived, but I want to leave the values for title and source as is. I'd write the following code, but I get a type error because no value for title or source were provided

const ns = pinecone.index<MyMetadata>(indexName).namespace(namespace);
await ns.update({ id: "abc123", metadata: { isArchived: true });
Type '{ isArchived: boolean; }' is missing the following properties from type '{ title: string; source: string; isArchived?: boolean | undefined; }': title, source

Solution

By wrapping the generic in Partial, we make it so that all of the fields in the interface are optional which is the intent of this method according to the documentation

If set_metadata is included, the values of the fields specified in it will be added or overwrite the previous value.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

N/A

@austin-denoble
Copy link
Contributor

austin-denoble commented Jan 31, 2024

Hey @omikader, thanks for the great PR description and fix. This looks like it makes sense to me, I'll let CI run and merge when ready, thank you!

Validating CI in a draft here since forks don't share secrets: #200

@austin-denoble austin-denoble mentioned this pull request Jan 31, 2024
7 tasks
Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI checks out here: #200

Thanks again for your contribution!

@austin-denoble austin-denoble merged commit 6461573 into pinecone-io:main Jan 31, 2024
4 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants