APIv3/src/main/java/net/frozenorb/apiv3/collections/Grant.java

48 lines
1.1 KiB
Java
Raw Normal View History

2016-02-08 02:51:02 +01:00
package net.frozenorb.apiv3.collections;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import lombok.Getter;
import lombok.ToString;
2016-02-08 02:54:27 +01:00
import net.frozenorb.apiv3.LiteFullJson;
import net.frozenorb.apiv3.utils.MongoUtils;
import java.util.List;
@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";
@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
}