コード例 #1
0
class Post(helo.Model):

    id = helo.Int(primary_key=True, auto=True)
    name = helo.VarChar(length=100)
    author = helo.Int(default=0)
    column = helo.Int(default=0)
    is_deleted = helo.Tinyint(default=0)
    created = helo.DateTime(default=datetime.datetime(2019, 10, 10))

    def __repr__(self):
        return '<{} {}>'.format(self.__class__.__name__, self.name)
コード例 #2
0
class Employee(People):

    salary = helo.Float()
    departmentid = helo.Int()
    phone = helo.VarChar(default='')
    email = helo.Email(length=100, default='')

    class Meta:
        indexes = [helo.K('idx_age_salary', ['age', 'salary'])]
コード例 #3
0
class Role(helo.Model):

    id = helo.Int(primary_key=True, auto=True)
    name = helo.VarChar(length=50)
    is_deleted = helo.Bool(default=False)
    create_at = helo.Timestamp(default=helo.ON_CREATE)
    update_at = helo.Timestamp(default=helo.ON_UPDATE)

    class Meta:
        name = 'role_'
コード例 #4
0
class Post(helo.Model):
    id = helo.Auto(comment='auto increment pk')
    title = helo.VarChar(length=100)
    content = helo.Text(encoding=helo.ENCODING.UTF8MB4)
    author = helo.Int(default=0)
    create_at = helo.Timestamp(default=helo.ON_CREATE)
    update_at = helo.Timestamp(default=helo.ON_UPDATE)

    class Meta:
        indexes = [
            helo.K('idx_title', 'title'),
            helo.K('idx_author', 'author'),
        ]
コード例 #5
0
class User(People):

    nickname = helo.VarChar(length=100)
    password = helo.VarChar(name='pwd')
    role = helo.Int(default=0)
    lastlogin = helo.DateTime(default=datetime.datetime.now, name='loginat')

    class Meta:
        db = 'helo'
        name = 'user_'
        indexes = (
            helo.K('idx_name', 'name'),
            helo.UK('unidx_nickname', 'nickname')
        )