Skip to content

Instantly share code, notes, and snippets.

@swanson
Created July 29, 2010 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swanson/497003 to your computer and use it in GitHub Desktop.
Save swanson/497003 to your computer and use it in GitHub Desktop.
class Question(Document):
score = IntField(required = True, default = 0)
voters = ListField(ReferenceField(User), default = lambda : [])
def vote_up(self, username):
Question.objects(id=self.id).update_one(inc__score=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment