-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds API for updating models and updating instances to use them #56
Conversation
With this change it is now possible to update a model definition in backwards compatible ways. Additionally when creating or updating model instance documents a modelVersion header value can be supplied to indicate that the instance uses the updated version of the model. Instances will always use the init event of a model (i.e. its first version) unless explicitly changed to a new version using the modelVersion header.
| // CBOR encoding doesn't support undefined values | ||
| const header = | ||
| params.shouldIndex == null ? undefined : { shouldIndex: params.shouldIndex } | ||
| const header: DocumentDataEventHeader = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter that we were sending an undefined header before if shouldIndex == null? We'll always pass the header into the function now, and it might be an empty map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should we just update createDataEventPayload to ignore both an undefined header and an empty one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or does it not matter if header is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I am 90% sure it doesn't matter but better safe than sorry. I'll change this to not set a header if shouldIndex or modelVersion are not set.
| * @returns The `CommitID` for the stream. | ||
| */ | ||
| getCurrentID(streamID: string): CommitID { | ||
| return new CommitID(2, streamID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructs a CommitID from just a stream id. Therefore the commit referenced will be the init commit
smrz2001
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
With this change it is now possible to update a model definition in backwards compatible ways. Additionally when creating or updating model instance documents a modelVersion header value can be supplied to indicate that the instance uses the updated version of the model. Instances will always use the init event of a model (i.e. its first version) unless explicitly changed to a new version using the modelVersion header.