Skip to content
Open
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
11 changes: 10 additions & 1 deletion redisco/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ def key(self, att=None):
return self._key[self.id][att]
else:
return self._key[self.id]

def delete(self):
"""Deletes the object from the datastore."""
pipeline = self.db.pipeline()
Expand All @@ -352,6 +351,16 @@ def delete(self):
pipeline.delete(self.key())
pipeline.execute()

#Clean up procedure used for cleaning up {ModelName}:id
#when there are no objects left inside {ModelName}:all.
#This only occurs when all the objects have been deleted.
#So,{ModelName}:id is left with the the last total count """

any_left = redisco.get_client().hexists(name=self._key,key=self._key['all'])
if not any_left:
pipeline.delete(self._key['id'])
pipeline.execute()

def is_new(self):
"""
Returns True if the instance is new.
Expand Down