Created
August 1, 2019 11:05
-
-
Save RyanSusana/4fd5285c08ee9c2493d67906378a3e58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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