Skip to content

Commit 4e8c5cf

Browse files
committed
Add support for collection updates
1 parent 40b3bbd commit 4e8c5cf

4 files changed

Lines changed: 38 additions & 11 deletions

File tree

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ Tests are also a good place to know how the the library works internally: [spec]
3333

3434
| Typesense Server | typesense-ruby |
3535
|------------------|----------------|
36-
| \>= v0.21.0 | \>= v0.13.0 |
37-
| \>= v0.20.0 | \>= v0.12.0 |
38-
| \>= v0.19.0 | \>= v0.11.0 |
39-
| \>= v0.18.0 | \>= v0.10.0 |
40-
| \>= v0.17.0 | \>= v0.9.0 |
41-
| \>= v0.16.0 | \>= v0.8.0 |
42-
| \>= v0.15.0 | \>= v0.7.0 |
43-
| \>= v0.12.1 | \>= v0.5.0 |
44-
| \>= v0.12.0 | \>= v0.4.0 |
45-
| <= v0.11 | <= v0.3.0 |
36+
| \>= v0.23.0 | \>= v0.14.0 |
37+
| \>= v0.21.0 | \>= v0.13.0 |
38+
| \>= v0.20.0 | \>= v0.12.0 |
39+
| \>= v0.19.0 | \>= v0.11.0 |
40+
| \>= v0.18.0 | \>= v0.10.0 |
41+
| \>= v0.17.0 | \>= v0.9.0 |
42+
| \>= v0.16.0 | \>= v0.8.0 |
43+
| \>= v0.15.0 | \>= v0.7.0 |
44+
| \>= v0.12.1 | \>= v0.5.0 |
45+
| \>= v0.12.0 | \>= v0.4.0 |
46+
| <= v0.11 | <= v0.3.0 |
4647

4748
## Development
4849

lib/typesense/collection.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def retrieve
1616
@api_call.get(endpoint_path)
1717
end
1818

19+
def update(update_schema)
20+
@api_call.patch(endpoint_path, update_schema)
21+
end
22+
1923
def delete
2024
@api_call.delete(endpoint_path)
2125
end

lib/typesense/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Typesense
4-
VERSION = '0.13.0'
4+
VERSION = '0.14.0'
55
end

spec/typesense/collection_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,28 @@
4747
expect(result).to eq(company_schema)
4848
end
4949
end
50+
describe '#update' do
51+
it 'updates the specified collection' do
52+
update_schema = {
53+
'fields' => [
54+
'name' => 'field', 'drop' => true
55+
]
56+
}
57+
stub_request(:patch, Typesense::ApiCall.new(typesense.configuration).send(:uri_for, '/collections/companies', typesense.configuration.nodes[0]))
58+
.with(
59+
body: update_schema,
60+
headers: {
61+
'X-Typesense-Api-Key' => typesense.configuration.api_key,
62+
'Content-Type' => 'application/json'
63+
}
64+
)
65+
.to_return(status: 200, body: JSON.dump(company_schema), headers: { 'Content-Type': 'application/json' })
66+
67+
result = companies_collection.update(update_schema)
68+
69+
expect(result).to eq(company_schema)
70+
end
71+
end
5072

5173
describe '#delete' do
5274
it 'deletes the specified collection' do

0 commit comments

Comments
 (0)