|
| 1 | +/* |
| 2 | + * Copyright (c) 2022 Contributors to the Eclipse Foundation |
| 3 | + * All rights reserved. This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | + * and Apache License v2.0 which accompanies this distribution. |
| 6 | + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 | + * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. |
| 8 | + * |
| 9 | + * You may elect to redistribute this code under either of these licenses. |
| 10 | + */ |
| 11 | + |
| 12 | +package org.jnosql.demo.se; |
| 13 | + |
| 14 | + |
| 15 | +import jakarta.enterprise.inject.se.SeContainer; |
| 16 | +import jakarta.enterprise.inject.se.SeContainerInitializer; |
| 17 | +import net.datafaker.Faker; |
| 18 | +import org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBTemplate; |
| 19 | + |
| 20 | +import java.util.Collections; |
| 21 | +import java.util.List; |
| 22 | +import java.util.stream.Collectors; |
| 23 | + |
| 24 | +import static org.eclipse.jnosql.communication.semistructured.SelectQuery.select; |
| 25 | + |
| 26 | + |
| 27 | +public class App1 { |
| 28 | + |
| 29 | + |
| 30 | + public static void main(String[] args) { |
| 31 | + |
| 32 | + try (SeContainer container = SeContainerInitializer.newInstance().initialize()) { |
| 33 | + |
| 34 | + var faker = new Faker(); |
| 35 | + |
| 36 | + ArangoDBTemplate template = container.select(ArangoDBTemplate.class).get(); |
| 37 | + Hero hero = template.insert(Hero.of(faker)); |
| 38 | + |
| 39 | + var query = select().from("Hero").where("_key").eq("iron_man").build(); |
| 40 | + List<Hero> heroes = template.<Hero>select(query).collect(Collectors.toList()); |
| 41 | + List<Hero> aql = template.<Hero>aql("FOR h IN Hero FILTER h.name == @id RETURN h", Collections.singletonMap("id", hero.name())) |
| 42 | + .collect(Collectors.toList()); |
| 43 | + System.out.println(heroes); |
| 44 | + System.out.println(aql); |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + } |
| 49 | + } |
| 50 | + private App1() { |
| 51 | + } |
| 52 | +} |
0 commit comments