Skip to content

Instantly share code, notes, and snippets.

@RyanSusana
Created August 1, 2019 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanSusana/4fd5285c08ee9c2493d67906378a3e58 to your computer and use it in GitHub Desktop.
Save RyanSusana/4fd5285c08ee9c2493d67906378a3e58 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
MongoClientURI uri = new MongoClientURI("uri");
MongoClient mongoClient = new MongoClient(uri);
final Elepy elepy = new Elepy()
.addConfiguration(AdminPanel.newAdminPanel())
.addModel(Products.class)
.onPort(7070);
elepy.start();
// after calling #start() you can use the elepy object to do some global calls
//Me adding the logged in permission to all incoming requests
elepy.http().before(ctx -> ctx.request().addPermissions(Permissions.LOGGED_IN));
final Crud<Product> products = elepy.getCrudFor(Product.class);
//me creating 1000 product objects
List<Products> seed = IntStream.range(0, 1000).mapToObj((id) -> new Product("id" + id)).collect(Collectors.toList());
//Adding products to DB
products.create(seed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment