Skip to main content

Better ORM wrapper of leancloud storage python sdk.

Project description

leancloud-better-storage-python

travis-ci codecov

更优雅且 pythonic 的方式使用 leancloud storage。

:construction: 施工中,文档也没有。有意参与或者疑问就开个 issue,看到回复。

快速开始

以一系列最简单的例子来说明使用方式。

模型声明

from leancloud_better_storage.storage.models import Model
from leancloud_better_storage.storage.fields import Field

class Product(Model):
    name = Field('product_name', nullable=False)
    price = Field(nullable=False)
    field3 = Field(nullable=False, default=1)

CRUD

创建和保存

product = Product.create(name='FirstProduct',price=100)
product.commit()

查找

代码仅演示查询语法

products = Product\
    .query()\
    .filter_by(name='LastProduct', price=100)\
    .and_()\
    .filter(Product.other_field > 10, Product.other_field < 100)\
    .or_()\
    .filter(Product.other_field < 10, Product.other_field > -10)\
    .order_by(Product.created_at.asc)\
    .find(skip=10, limit=100)  # also support first(), count()

更新

product = Product.query().filter_by(name='FirstProduct').first()
product.name = 'LastProduct'
product.commit()

删除

product = Product.query().filter_by(name='FirstProduct').first()
product.drop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leancloud-better-storage-0.1.0.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

leancloud_better_storage-0.1.0-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page