flask+mongoengine开发tips(二)

1.mongoengine全部原子操作

set – set a particular value
unset – delete a particular value (since MongoDB v1.3+)
inc – increment a value by a given amount
dec – decrement a value by a given amount
push – append a value to a list
push_all – append several values to a list
pop – remove the first or last element of a list 
pull – remove a value from a list
pull_all – remove several values from a list
add_to_set – add value to a list only if its not in the list already

2.mongoengine全部查询操作

ne–not equal to
lt–less than
lte – less than or equal to 
gt – greater than
gte – greater than or equal to
not – negate a standard check, may be used before other operators
in – value is in list (a list of values should be provided)
nin – value is not in list (a list of values should be provided)
mod – value % x == y, where x and y are two provided values
all – every item in list of values provided is in array
size – the size of the array is
exists – value for field exists

3.mongoengine全部field格式

BinaryField
BooleanField
ComplexDateTimeField
DateTimeField
DecimalField
DictField
DynamicField
EmailField
EmbeddedDocumentField
FileField
FloatField
GenericEmbeddedDocumentField 
GenericReferenceField
GeoPointField
ImageField
IntField
ListField
MapField
ObjectIdField
ReferenceField 
SequenceField
SortedListField 
StringField
URLField
UUIDField

4.mongoengine全部字段参数

db_field (Default: None) 数据库字段名
required (Default: False) 插入时是否是必须字段
default (Default: None) 默认插入值
unique (Default: False) 是否唯一
unique_with (Default: None) 和某个或某些(用逗号分隔)字段联合唯一
primary_key (Default: False) 是否主键
choices (Default: None) 将字段的值限定为某几个
help_text (Default: None) 帮助文本
verbose_name (Default: None) 可选的人类可读的字段名
    原文作者:敲键盘的猫
    原文地址: https://segmentfault.com/a/1190000000494893
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞