feat: adds API for updating models and updating instances to use them#56
feat: adds API for updating models and updating instances to use them#56nathanielc merged 5 commits intomainfrom
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.
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.
Or should we just update createDataEventPayload to ignore both an undefined header and an empty one?
There was a problem hiding this comment.
Or does it not matter if header is empty?
There was a problem hiding this comment.
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.
constructs a CommitID from just a stream id. Therefore the commit referenced will be the init commit
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.