class MyMulti(Model): class Meta: ordering = ['f1', 'f2'] f1 = fields.IntField() f2 = fields.IntField() other = fields.StringField()
class MyModel( Model ): class Meta: storage = FooStorage int_type = fields.IntField(primary_key=True) str_type = fields.StringField() date_type = fields.DateTimeField()
class MyModel( Model ): class Meta: filename = 'foo.bar' int_type = fields.IntField(primary_key=True) str_type = fields.StringField() date_type = fields.DateTimeField()
class MyModel( Model ): class Meta: ordering = ['int_type','str_type','dt_type'] filename = tfile.name int_type = fields.IntField(primary_key=True) str_type = fields.StringField() dt_type = fields.DateTimeField()
class MyModel(Model): class Meta: ordering = ['int_type', 'str_type', 'dt_type'] int_type = fields.IntField(primary_key=True) str_type = fields.StringField() dt_type = fields.DateTimeField() @property def iter_type(self): return [self.int_type]
class Episode(alkali.Model): class Meta: storage = RssLoader('https://pythonbytes.fm/episodes/rss') guid = fields.UUIDField(primary_key=True) title = fields.StringField() published = fields.DateTimeField() itunes_episode = fields.IntField() link = fields.StringField() description = fields.StringField() def __str__(self): return f"<Epsiode {self.itunes_episode} - {self.title}>" @property def num(self): return self.itunes_episode
class AutoModel2(Model): auto = fields.IntField(primary_key=True, auto_increment=True) creation = fields.DateTimeField(auto_now_add=True) modified = fields.DateTimeField(auto_now=True) f1 = fields.StringField() f2 = fields.StringField()
class MyDepModel(Model): pk1 = fields.IntField(primary_key=True) foreign = fields.ForeignKey(MyModel)
class MyMulti(Model): pk1 = fields.IntField(primary_key=True) pk2 = fields.IntField(primary_key=True) other = fields.StringField()
class MyModel2(Model): class Meta: storage = FooStorage pk1 = fields.IntField(primary_key=True)
class MyModel2( Model ): class Meta: filename = tfile.name int_type = fields.IntField(primary_key=True)