2016-02-08 02:51:02 +01:00
|
|
|
package net.frozenorb.apiv3.collections;
|
|
|
|
|
2016-02-08 03:06:41 +01:00
|
|
|
import io.vertx.core.AsyncResult;
|
|
|
|
import io.vertx.core.Handler;
|
|
|
|
import io.vertx.core.json.JsonObject;
|
|
|
|
import lombok.Getter;
|
2016-02-08 02:52:03 +01:00
|
|
|
import lombok.ToString;
|
2016-02-08 02:54:27 +01:00
|
|
|
import net.frozenorb.apiv3.LiteFullJson;
|
2016-02-08 03:06:41 +01:00
|
|
|
import net.frozenorb.apiv3.utils.MongoUtils;
|
|
|
|
|
|
|
|
import java.util.List;
|
2016-02-08 02:52:03 +01:00
|
|
|
|
|
|
|
@ToString
|
2016-02-08 02:54:27 +01:00
|
|
|
public final class Grant implements LiteFullJson {
|
2016-02-08 02:51:02 +01:00
|
|
|
|
|
|
|
public static final String COLLECTION_NAME = "grant";
|
|
|
|
|
2016-02-08 03:06:41 +01:00
|
|
|
@Getter private String id;
|
|
|
|
|
|
|
|
public static void findAll(Handler<AsyncResult<List<Grant>>> callback) {
|
|
|
|
MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), Grant::new, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void findById(String id, Handler<AsyncResult<Grant>> callback) {
|
|
|
|
MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Grant::new, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
private Grant(JsonObject json) {
|
|
|
|
this.id = json.getString("_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
public JsonObject toLiteJson() {
|
|
|
|
JsonObject json = new JsonObject();
|
|
|
|
|
|
|
|
json.put("_id", id);
|
|
|
|
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
public JsonObject toFullJson() {
|
|
|
|
JsonObject json = toLiteJson();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
2016-02-08 02:51:02 +01:00
|
|
|
}
|