Skip to content

Commit 872e65a

Browse files
committed
Add collection update end-point.
1 parent 52c33d3 commit 872e65a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

examples/collection_operations.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,17 @@
120120
})
121121
print(import_results)
122122

123+
# Schema change: add optional field
124+
schema_change = {"fields": [{"name": "in_stock", "optional": True, "type": "bool"}]}
125+
print(client.collections['books'].update(schema_change))
126+
127+
# Drop the field
128+
schema_change = {"fields": [{"name": "in_stock", "drop": True}]}
129+
print(client.collections['books'].update(schema_change))
130+
123131
# Deleting documents matching a filter query
124132
print(client.collections['books'].documents.delete({'filter_by': 'ratings_count: 4780653'}))
125133

126134
# Drop the collection
127-
128135
drop_response = client.collections['books'].delete()
129136
print(drop_response)

typesense/collection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ def _endpoint_path(self):
1818
def retrieve(self):
1919
return self.api_call.get(self._endpoint_path())
2020

21+
def update(self, schema_change):
22+
return self.api_call.patch(self._endpoint_path(), schema_change)
23+
2124
def delete(self):
2225
return self.api_call.delete(self._endpoint_path())

0 commit comments

Comments
 (0)