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

Add update model endpoint #739

Merged
merged 1 commit into from
Sep 25, 2023
Merged

Add update model endpoint #739

merged 1 commit into from
Sep 25, 2023

Conversation

a3957273
Copy link
Member

No description provided.

@@ -206,6 +206,20 @@ export async function updateModelCard(
return revision
}

export type UpdateModelParams = Pick<ModelInterface, 'name' | 'description' | 'visibility'>
export async function updateModel(user: UserDoc, modelId: string, diff: Partial<UpdateModelParams>) {
Copy link
Member

Choose a reason for hiding this comment

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

Does the 'diff' stand for different/difference??

Copy link
Member

Choose a reason for hiding this comment

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

I would assume so, a Partial is (like the name suggests) a type that contains some but not all of the properties of a given type.

I think we should probably rename this, but I am going to approve in case you're 100% set on this naming @a3957273

@@ -206,6 +206,20 @@ export async function updateModelCard(
return revision
}

export type UpdateModelParams = Pick<ModelInterface, 'name' | 'description' | 'visibility'>
export async function updateModel(user: UserDoc, modelId: string, diff: Partial<UpdateModelParams>) {
const model = await getModelById(user, modelId)
Copy link
Member

Choose a reason for hiding this comment

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

Why didn't you use findByIdAndUpdate()?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to check the authorisation first.

@a3957273 a3957273 merged commit 03ba4eb into main Sep 25, 2023
@a3957273 a3957273 deleted the feature/update-model branch September 25, 2023 13:59
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.

4 participants