github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/patch_command_data.go (about) 1 package ravendb 2 3 type PatchCommandData struct { 4 *CommandData 5 6 patch *PatchRequest 7 patchIfMissing *PatchRequest 8 } 9 10 // NewPatchCommandData creates CommandData for Delete Attachment command 11 // TODO: return a concrete type? 12 func NewPatchCommandData(id string, changeVector *string, patch *PatchRequest, patchIfMissing *PatchRequest) ICommandData { 13 // TODO: verify args 14 res := &PatchCommandData{ 15 CommandData: &CommandData{ 16 ID: id, 17 Type: CommandPatch, 18 ChangeVector: changeVector, 19 }, 20 patch: patch, 21 patchIfMissing: patchIfMissing, 22 } 23 return res 24 } 25 26 func (d *PatchCommandData) serialize(conventions *DocumentConventions) (interface{}, error) { 27 res := d.baseJSON() 28 res["Patch"] = d.patch.Serialize() 29 30 if d.patchIfMissing != nil { 31 res["PatchIfMissing"] = d.patchIfMissing.Serialize() 32 } 33 return res, nil 34 }