use of org.immutables.mongo.repository.RepositorySetup in project immutables by immutables.
the class Ent method main.
public static void main(String... args) throws UnknownHostException {
MongoClient client = new MongoClient("localhost");
RepositorySetup setup = RepositorySetup.builder().database(client.getDB("test")).executor(MoreExecutors.listeningDecorator(Executors.newCachedThreadPool())).gson(new GsonBuilder().registerTypeAdapterFactory(new GsonAdaptersEnt()).create()).build();
EntRepository repository = new EntRepository(setup);
EntRepository.Criteria where = repository.criteria().uuid("8b7a881c-6ccb-4ada-8f6a-60cc99e6aa20").actionIn("BAN", "IPBAN");
Criteria or = where.expiresAbsent().or().with(where).expiresGreaterThan(TimeInstant.of(1467364749679L));
System.out.println(or);
repository.find(or).fetchAll().getUnchecked();
}
use of org.immutables.mongo.repository.RepositorySetup in project immutables by immutables.
the class ManualStorage method main.
public static void main(String... args) {
RepositorySetup setup = RepositorySetup.forUri("mongodb://localhost/test");
ItemRepository items = new ItemRepository(setup);
items.findAll().deleteAll().getUnchecked();
ItemRepository.Criteria where = items.criteria();
FluentFuture<Integer> inserted = items.insert(ImmutableItem.builder().id("1").binary(Binary.create(new byte[] { 1, 2, 3 })).build());
inserted.getUnchecked();
List<Item> all = items.find(where).fetchAll().getUnchecked();
String json = createGson().toJson(all, LIST_ITEMS);
System.out.println(json);
}
Aggregations