예제 #1
0
파일: city.py 프로젝트: fuzeman/byte
class City(Model):
    id = Property(str, name='geonameid', primary_key=True)

    name = Property(str)

    country = Property(str)
    subcountry = Property(str)
예제 #2
0
class Artist(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)

    title = Property(str)
예제 #3
0
class User(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)

    username = Property(str)
    password = Property(str)
예제 #4
0
파일: album.py 프로젝트: fuzeman/byte
class Album(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)
    artist = Property(Artist)

    title = Property(str)
예제 #5
0
class User(Model):
    id = Property(int, primary_key=True)

    username = Property(str)
    password = Property(str)

    created_at = Property(datetime, default=lambda: datetime.now())
    updated_at = Property(datetime, default=lambda: datetime.now())
예제 #6
0
    def __bind_property_relation(cls, properties, key, prop):
        # Bind `prop` (to ensure metadata is available)
        prop.bind(cls, key + '_id')

        # Create identifier property
        p_id = Property(prop.relation.value_type)
        p_id.bind(cls, key + '_id')

        # Create resolve property
        p_resolve = RelationProperty(p_id, prop.value_type)
        p_resolve.bind(cls, key)

        # Store resolve property on model
        setattr(cls, key, p_resolve)

        # Store resolve property on model `Properties`
        setattr(properties, key, p_resolve)
        properties.__all__[key] = p_resolve

        # Store identifier property on model `Properties`
        setattr(properties, key + '_id', p_id)
        properties.__all__[key + '_id'] = p_id
예제 #7
0
파일: artist.py 프로젝트: fuzeman/byte
class Artist(Model):
    id = Property(int, primary_key=True)

    title = Property(str)
예제 #8
0
class Album(Model):
    id = Property(int, primary_key=True)
    artist = Property(Artist)

    title = Property(str)
예제 #9
0
파일: track.py 프로젝트: fuzeman/byte
class Track(Model):
    id = Property(int, primary_key=True)
    artist = Property(Artist)
    album = Property(Album)

    title = Property(str)