Skip to content

Commit

Permalink
Added a unique index requirement to the text field of each statement.
Browse files Browse the repository at this point in the history
This change should prevent any possible duplicate key issues.
  • Loading branch information
gunthercox committed May 8, 2016
1 parent e5a9869 commit 9829662
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chatterbot/adapters/storage/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self, **kwargs):
# The mongo collection of statement documents
self.statements = self.database['statements']

# Set a requirement for the text attribute to be unique
self.statements.create_index('text', unique=True)

def count(self):
return self.statements.count()

Expand Down

0 comments on commit 9829662

Please sign in to comment.