Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCondition ¶
Types ¶
type Condition ¶
type Condition interface { RegexFilter(key, pattern string) *filter ID(id interface{}) *filter // Eq Equals a Specified Value //{ qty: 20 } //Field in Embedded Document Equals a Value //{"item.name": "ab" } // Equals an Array Value //{ tags: [ "A", "B" ] } Eq(key string, value interface{}) *filter // Gt {field: {$gt: value} } > Gt(key string, gt interface{}) *filter // Gte { qty: { $gte: 20 } } >= Gte(key string, gte interface{}) *filter // In { field: { $in: [<value1>, <value2>, ... <valueN> ] } } // tags: { $in: [ /^be/, /^st/ ] } } // in []string []int ... In(key string, in interface{}) *filter // Lt {field: {$lt: value} } < Lt(key string, lt interface{}) *filter // Lte { field: { $lte: value} } <= Lte(key string, lte interface{}) *filter // Ne {field: {$ne: value} } != Ne(key string, ne interface{}) *filter // Nin { field: { $nin: [ <value1>, <value2> ... <valueN> ]} } the field does not exist. Nin(key string, nin interface{}) *filter // And { $and: [ { <expression1> }, { <expression2> } , ... , { <expressionN> } ] } //$and: [ // { $or: [ { qty: { $lt : 10 } }, { qty : { $gt: 50 } } ] }, // { $or: [ { sale: true }, { price : { $lt : 5 } } ] } // ] And(filter Condition) *filter // Not { field: { $not: { <operator-expression> } } } //not and Regular Expressions //{ item: { $not: /^p.*/ } } Not(key string, not interface{}) *filter // Nor { $nor: [ { price: 1.99 }, { price: { $exists: false } }, // { sale: true }, { sale: { $exists: false } } ] } // price != 1.99 || sale != true || sale exists || sale exists Nor(filter Condition) *filter // Or { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } Or(filter Condition) *filter Exists(key string, exists bool, filter ...Condition) *filter // Type { field: { $type: <BSON type> } } // { "_id" : 1, address : "2030 Martian Way", zipCode : "90698345" }, // { "_id" : 2, address: "156 Lunar Place", zipCode : 43339374 }, // db.find( { "zipCode" : { $type : 2 } } ); or db.find( { "zipCode" : { $type : "string" } } // return { "_id" : 1, address : "2030 Martian Way", zipCode : "90698345" } Type(key string, t interface{}) *filter // Expr Allows the use of aggregation expressions within the query language. //{ $expr: { <expression> } } //$expr can build query expressions that compare fields from the same document in a $match stage //todo 没用过,不知道行不行。。https://docs.mongodb.com/manual/reference/operator/query/expr/#op._S_expr Expr(filter Condition) *filter // Regex todo 简单实现,后续增加支持 Regex(key string, value interface{}) *filter Filters() bson.D A() bson.A }
func DefaultCondition ¶
func DefaultCondition() Condition
type TagMaker ¶
type TagMaker interface { // MakeTag makes tag for the field the fieldIndex in the structureType. // Result should depends on constant parameters of creation of the TagMaker and parameters // passed to the MakeTag. The MakeTag should not produce side effects (like a pure function). MakeTag(structureType reflect.Type, fieldIndex int) reflect.StructTag }
Click to show internal directories.
Click to hide internal directories.