Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 588c3e0

Browse files
committed
Add db.remove method
1 parent 45839a2 commit 588c3e0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

orbitdbapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.0.rc.1.dev2'
1+
__version__ = '0.1.0.rc.1.dev3'

orbitdbapi/db.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def queryable(self):
5555
def putable(self):
5656
return 'put' in self.__params.get('capabilities', {})
5757

58+
@property
59+
def removeable(self):
60+
return 'remove' in self.__params.get('capabilities', {})
61+
5862
def info(self):
5963
endpoint = '/'.join(['db', self.__id_safe])
6064
return self.__client._call('get', endpoint)
@@ -112,6 +116,16 @@ def index(self):
112116
self.__cache = result
113117
return result
114118

119+
def remove(self, item):
120+
if not self.removeable:
121+
raise CapabilityError('Db does not have remove capability')
122+
item = str(item)
123+
endpoint = '/'.join(['db', self.__id_safe, item])
124+
return self.__client._call('delete', endpoint)
125+
115126
def unload(self):
116127
endpoint = '/'.join(['db', self.__id_safe])
117128
return self.__client._call('delete', endpoint)
129+
130+
class CapabilityError(Exception):
131+
pass

0 commit comments

Comments
 (0)