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

Collection update. #119

Merged
merged 8 commits into from
Jul 7, 2022
Merged

Collection update. #119

merged 8 commits into from
Jul 7, 2022

Conversation

happy-san
Copy link
Collaborator

@happy-san happy-san commented May 15, 2022

Change Summary

Support collection update operation.
#118

PR Checklist

@@ -70,6 +71,28 @@ class Field extends Equatable {
List<Object> get props => [name, type, isMultivalued];
}

class DroppableField extends Field {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @kishorenc
Since only fields can be updated as of now, I've created DroppableField class to be used in the update function.

Copy link
Member

@kishorenc kishorenc May 16, 2022

Choose a reason for hiding this comment

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

@happy-san I think having an UpdateSchema class as detailed in the issue is better because we can add other updatable fields to it in future. By using a List< DroppableField> that flexibility is lost. With UpdateSchema, the update operation will look like this:

final updateSchema = UpdateSchema(
  {
    Field('company_category', Type.string),
    Field('num_employees', drop: true)
  }
);
await client.collection('companies').update(updateSchema);

This also means that we need to add a drop property to the field. We debated the semantics of doing this, but any alternative way of representing this became way too verbose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, I'll update this accordingly.

}
}

class CollectionUpdateSchema extends BaseSchema {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kishorenc I've added CollectionUpdateSchema.

@happy-san happy-san merged commit 857f3cd into master Jul 7, 2022
@happy-san happy-san deleted the chores branch July 7, 2022 15:45
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