Last active
February 15, 2022 11:21
-
-
Save ijokarumawak/bb2e2609af521be0646d 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
@RequestMapping("/all") | |
public List<FlightPath> findAll(@RequestParam String from, @RequestParam String to) { | |
N1qlQuery query = N1qlQuery.simple(select("a.name", "s.flight", "s.utc", "r.equipment") | |
.from(i(bucket.name()).as("r")) | |
.unnest("r.schedule").as("s") | |
.join(i(bucket.name()).as("a").toString()).onKeys("r.airlineid") | |
.where(x("r.sourceairport").eq(s(from)).and(x("r.destinationairport").eq(s(to)))) | |
.orderBy(asc("s.utc")) | |
); | |
List<FlightPath> flightPaths = new ArrayList<>(); | |
bucket.query(query).forEach(row -> | |
flightPaths.add(FlightPath.create(row.value(), from, to))); | |
return flightPaths; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment