code: def set_to(cls, name, num):
          
          if num < 0:
              raise CounterValueError('Counter[%s] can not be set to %s' % (
                                      name, num))
          else:
              counter = cls.collection.find_and_modify(
                  {'name': name},
                  {'$set': {'seq': num}},
                  new=True,
                  upsert=True
              )
              return counter['seq']
docs: Set counter of ``name`` to ``num``.