1 module hunt.database.query.Expr; 2 3 import hunt.database.query.Expression; 4 import hunt.database.query.Common; 5 import hunt.database.query.Comparison; 6 7 import hunt.logging; 8 9 class Expr 10 { 11 Comparison!T eq(T)(string key,T value) 12 { 13 return new Comparison!T(key,CompareType.eq,value); 14 } 15 Comparison!T ne(T)(string key,T value) 16 { 17 return new Comparison!T(key,CompareType.ne,value); 18 } 19 Comparison!T gt(T)(string key,T value) 20 { 21 return new Comparison!T(key,CompareType.gt,value); 22 } 23 Comparison!T lt(T)(string key,T value) 24 { 25 return new Comparison!T(key,CompareType.lt,value); 26 } 27 Comparison!T ge(T)(string key,T value) 28 { 29 return new Comparison!T(key,CompareType.ge,value); 30 } 31 Comparison!T le(T)(string key,T value) 32 { 33 return new Comparison!T(key,CompareType.le,value); 34 } 35 Comparison!T like(T)(string key,T value) 36 { 37 return new Comparison!T(key,CompareType.like,value); 38 } 39 40 string andX(string[] args...) 41 { 42 string cond; 43 cond ~= " ( "; 44 foreach(idx ,arg ; args) 45 { 46 cond ~= arg; 47 if (idx != args.length - 1) 48 cond ~= " AND "; 49 } 50 cond ~= " ) "; 51 return cond; 52 } 53 54 string orX(string[] args...) 55 { 56 string cond; 57 cond ~= " ( "; 58 foreach(idx ,arg ; args) 59 { 60 cond ~= arg; 61 if (idx != args.length - 1) 62 cond ~= " OR "; 63 } 64 cond ~= " ) "; 65 // logDebug("orX : ",cond); 66 return cond; 67 } 68 69 }