Skip to content

Commit

Permalink
Expose all QueryOperationOptions properties for users.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejaszyk committed Feb 29, 2024
1 parent 8073116 commit 9c92032
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
12 changes: 6 additions & 6 deletions delete_by_query_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ func NewDeleteByIndexCommand(conventions *DocumentConventions, queryToDelete *In
func (c *DeleteByIndexCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
options := c.options

url := node.URL + "/databases/" + node.Database + fmt.Sprintf("/queries?allowStale=%v", options.allowStale)
url := node.URL + "/databases/" + node.Database + fmt.Sprintf("/queries?allowStale=%v", options.AllowStale)

if options.maxOpsPerSecond != 0 {
url += "&maxOpsPerSec=" + strconv.Itoa(options.maxOpsPerSecond)
if options.MaxOpsPerSecond != 0 {
url += "&maxOpsPerSec=" + strconv.Itoa(options.MaxOpsPerSecond)
}

url += fmt.Sprintf("&details=%v", options.retrieveDetails)
url += fmt.Sprintf("&details=%v", options.RetrieveDetails)

if options.staleTimeout != 0 {
url += "&staleTimeout=" + durationToTimeSpan(options.staleTimeout)
if options.StaleTimeout != 0 {
url += "&staleTimeout=" + durationToTimeSpan(options.StaleTimeout)
}

m := jsonExtensionsWriteIndexQuery(c.conventions, c.queryToDelete)
Expand Down
19 changes: 13 additions & 6 deletions patch_by_query_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ func NewPatchByQueryOperation(queryToUpdate string) *PatchByQueryOperation {
}
}

func NewPatchByQueryOperationWithOptions(queryToUpdate string, options *QueryOperationOptions) *PatchByQueryOperation {
return &PatchByQueryOperation{
_queryToUpdate: NewIndexQuery(queryToUpdate),
_options: options,
}
}

func (o *PatchByQueryOperation) GetCommand(store *DocumentStore, conventions *DocumentConventions, cache *httpCache) (RavenCommand, error) {
var err error
o.Command, err = NewPatchByQueryCommand(conventions, o._queryToUpdate, o._options)
Expand Down Expand Up @@ -62,16 +69,16 @@ func NewPatchByQueryCommand(conventions *DocumentConventions, queryToUpdate *Ind
func (c *PatchByQueryCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
_options := c._options

url := node.URL + "/databases/" + node.Database + fmt.Sprintf("/queries?allowStale=%v", _options.allowStale)
url := node.URL + "/databases/" + node.Database + fmt.Sprintf("/queries?allowStale=%v", _options.AllowStale)

if _options.maxOpsPerSecond != 0 {
url += "&maxOpsPerSec=" + strconv.Itoa(_options.maxOpsPerSecond)
if _options.MaxOpsPerSecond != 0 {
url += "&maxOpsPerSec=" + strconv.Itoa(_options.MaxOpsPerSecond)
}

url += fmt.Sprintf("&details=%v", _options.retrieveDetails)
url += fmt.Sprintf("&details=%v", _options.RetrieveDetails)

if _options.staleTimeout != 0 {
url += "&staleTimeout=" + durationToTimeSpan(_options.staleTimeout)
if _options.StaleTimeout != 0 {
url += "&staleTimeout=" + durationToTimeSpan(_options.StaleTimeout)
}

q := jsonExtensionsWriteIndexQuery(c._conventions, c._queryToUpdate)
Expand Down
8 changes: 4 additions & 4 deletions query_operation_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "time"

// QueryOperationOptions represents options for query operation
type QueryOperationOptions struct {
maxOpsPerSecond int
allowStale bool
staleTimeout time.Duration
retrieveDetails bool
MaxOpsPerSecond int
AllowStale bool
StaleTimeout time.Duration
RetrieveDetails bool
}

0 comments on commit 9c92032

Please sign in to comment.