1. Query.fields (). Include ("IDFA"). Include ("IMEI"). Include ("id"). include ("OS"). These fields are included in the return data
2.
①
list<criteria> criterias = new arraylist<> ();
Criterias.add (Criteria.where ("Time"). GT ("2017-09-20 10:02:26"));
Criterias.add (Criteria.where ("time"). Lt ("2017-09-27 10:02:26"));
Criterias.add (Criteria.where ("IMEI"). Is ("9686854123"));
Query.addcriteria (New Criteria () Andoperator (Criterias.toarray (new criteria[0]));
Ii
ToArray explanation
Public <T> t[] ToArray (t[] a) {
if (a.length < size)
a = (t[]) Java.lang.reflect.Array.
Newinstance (A.getclass (). Getcomponenttype (), size);
system.arraycopy (elementdata, 0, a, 0, size);
if (a.length > Size)
A[size] = null;
return A;
}
The following query statement is obtained by ①
{"Channel":"Jinritoutiao","$and": [ {"IMEI":"96868541236"}, {" Time": {"$lt":"2017-09-27 10:02:26"}}, {" Time": {"$GT":"2017-09-20 10:02:26"}}]
}
3.
Query.addcriteria (Criteria.where ("Key"). Is ("Value"));
from the source below can be seen above the key cannot be a duplicate value
PublicQuery Addcriteria (criteriadefinition criteriadefinition) {criteriadefinition existing= (criteriadefinition) This. Criteria.Get(Criteriadefinition.getkey ()); String Key=Criteriadefinition.getkey (); if(Existing = =NULL) { This. Criteria.put (key, criteriadefinition); return This; } Else { Throw NewInvalidmongodbapiusageexception ("Due to limitations of the com.mongodb.BasicDBObject, you can ' t add a second '"+ key +"' criteria."+"Query already contains '"+ existing.getcriteriaobject () +"'."); } }
MONGO in Java