def getNewID(self):
        """

            :desc: Get a new ID by either incrementing the currentMax ID
                   or using an unusedID
            :returns: A new, valid, ID
            :rval: int
        """
        idCollection = self.noteDB['IDs']
        query = {"unusedIDs": {"$exists": True}}
        unusedIDs = idCollection.find_one(query)['unusedIDs']

        if not unusedIDs:
            query = {"currentMax": {"$exists": True}}
            ID = idCollection.find_one(query)['currentMax'] + 1
            idCollection.update({"currentMax": ID - 1}, {"currentMax": ID})
        else:
            query = {"unusedIDs": {"$exists": True}}
            unusedIDs = idCollection.find_one(query)['unusedIDs']
            ID = min(unusedIDs)
            unusedIDs.remove(ID)
            idCollection.update({"unusedIDs": {"$exists": True}},
                                {"$set": {"unusedIDs": unusedIDs}})

        return int(ID)
def getNewID ( self ) : idCollection = self . noteDB [ 'IDs' ] query = { "unusedIDs" : { "$exists" : True } } unusedIDs = idCollection . find_one ( query ) [ 'unusedIDs' ] if not unusedIDs : query = { "currentMax" : { "$exists" : True } } ID = idCollection . find_one ( query ) [ 'currentMax' ] + 1 idCollection . update ( { "currentMax" : ID - 1 } , { "currentMax" : ID } ) else : query = { "unusedIDs" : { "$exists" : True } } unusedIDs = idCollection . find_one ( query ) [ 'unusedIDs' ] ID = min ( unusedIDs ) unusedIDs . remove ( ID ) idCollection . update ( { "unusedIDs" : { "$exists" : True } } , { "$set" : { "unusedIDs" : unusedIDs } } ) return int ( ID )
:desc: Get a new ID by either incrementing the currentMax ID
                   or using an unusedID
            :returns: A new, valid, ID
            :rval: int