add some syntax sugar using statics
This commit is contained in:
@@ -32,6 +32,17 @@ public class Query {
|
||||
|
||||
private int limit;
|
||||
|
||||
|
||||
/**
|
||||
* Static factory method to create a Query using the provided criteria
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Query query(Criteria critera) {
|
||||
return new Query(critera);
|
||||
}
|
||||
|
||||
public Query() {
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,16 @@ public class Update {
|
||||
|
||||
private HashMap<String, Object> criteria = new LinkedHashMap<String, Object>();
|
||||
|
||||
/**
|
||||
* Static factory method to create an Update using the provided key
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Update update(String key, Object value) {
|
||||
return new Update().set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update using the $set update modifier
|
||||
*
|
||||
@@ -41,7 +51,7 @@ public class Update {
|
||||
criteria.put("$set", Collections.singletonMap(key, convertValueIfNecessary(value)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update using the $unset update modifier
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user