def update_count(cat_id): ''' Update the count of certain category. ''' entry2 = TabTag.update(count=TabPost2Tag.select().where( TabPost2Tag.tag_id == cat_id).count()).where(TabTag.uid == cat_id) entry2.execute()
def update_count(cat_id): ''' Update the count of certain category. ''' # Todo: the record not valid should not be counted. entry2 = TabTag.update(count=TabPost2Tag.select().where( TabPost2Tag.tag_id == cat_id).count()).where(TabTag.uid == cat_id) entry2.execute()
def update_count(cat_id): ''' Update the count of certain category. ''' entry2 = TabTag.update(count=TabPost2Tag.select().join( TabPost, on=(TabPost.uid == TabPost2Tag.post_id)).where( (TabPost.valid == 1) & (TabPost2Tag.tag_id == cat_id)).count()).where( TabTag.uid == cat_id) entry2.execute()
def update(uid, post_data): ''' Update the category. ''' raw_rec = TabTag.get(TabTag.uid == uid) entry = TabTag.update( name=post_data['name'] if 'name' in post_data else raw_rec.name, slug=post_data['slug'] if 'slug' in post_data else raw_rec.slug, order=post_data['order'] if 'order' in post_data else raw_rec.order, kind=post_data['kind'] if 'kind' in post_data else raw_rec.kind, pid=post_data['pid'], ).where(TabTag.uid == uid) entry.execute()