Python mongoengine 模块,IntField() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用mongoengine.IntField()

项目:mongoengine_utils    作者:aiscenblue    | 项目源码 | 文件源码
def setUp(self):
        """Setup."""
        class ExclusionModel(gj.Document):
            to_json_exclude = db.StringField(exclude_to_json=True)
            from_json_exclude = db.IntField(exclude_from_json=True)
            json_exclude = db.StringField(exclude_json=True)
            required = db.StringField(required=True)

        self.cls = ExclusionModel
        self.test_data = []
        for counter in range(3):
            data_el = {
                "to_json_exclude": ("To JSON Exclusion {}").format(counter),
                "from_json_exclude": counter,
                "json_exclude": ("JSON Exclusion {}").format(counter),
                "required": ("Required {}").format(counter)
            }
            model = self.cls(**data_el)
            model.save()
            self.test_data.append(data_el)
项目:mongoengine_utils    作者:aiscenblue    | 项目源码 | 文件源码
def setUp(self):
        """Setup."""
        class ExclusionModel(gj.Document):
            to_json_exclude = db.StringField(exclude_to_json=True)
            from_json_exclude = db.IntField(exclude_from_json=True)
            json_exclude = db.StringField(exclude_json=True)
            required = db.StringField(required=True)

        self.cls = ExclusionModel
        self.data = {
            "to_json_exclude": "Hello",
            "from_json_exclude": 10234,
            "json_exclude": "Hi",
            "required": "World"
        }
        self.model = self.cls(**self.data)