Skip to content

Commit 03d737b

Browse files
committed
Add query parameters
1 parent 735ab69 commit 03d737b

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ typesense-server-peers
1515

1616
# rspec failure tracking
1717
.rspec_status
18+
typesense-data

lib/typesense/document.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def delete
1616
@api_call.delete(endpoint_path)
1717
end
1818

19-
def update(partial_document)
20-
@api_call.patch(endpoint_path, partial_document)
19+
def update(partial_document, query_parameters = {})
20+
@api_call.patch(endpoint_path, partial_document, query_parameters)
2121
end
2222

2323
private

lib/typesense/documents.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ def initialize(collection_name, api_call)
1212
@documents = {}
1313
end
1414

15-
def create(document)
16-
@api_call.post(endpoint_path, document)
15+
def create(document, query_parameters = {})
16+
@api_call.post(endpoint_path, document, query_parameters)
1717
end
1818

19-
def upsert(document)
20-
@api_call.post(endpoint_path, document, action: :upsert)
19+
def upsert(document, query_parameters = {})
20+
@api_call.post(endpoint_path, document, query_parameters.merge(action: :upsert))
2121
end
2222

23-
def update(document)
24-
@api_call.post(endpoint_path, document, action: :update)
23+
def update(document, query_parameters = {})
24+
@api_call.post(endpoint_path, document, query_parameters.merge(action: :update))
2525
end
2626

2727
def create_many(documents, options = {})

spec/typesense/documents_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
headers: {
5050
'X-Typesense-Api-Key' => typesense.configuration.api_key,
5151
'Content-Type' => 'application/json'
52+
},
53+
query: {
54+
'dirty_values' => 'reject'
5255
})
5356
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
5457

0 commit comments

Comments
 (0)