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

Expose all QueryOperationOptions properties for users. #207

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading