Skip to content

Instantly share code, notes, and snippets.

@ijokarumawak
Last active February 15, 2022 11:21
Show Gist options
  • Save ijokarumawak/bb2e2609af521be0646d to your computer and use it in GitHub Desktop.
Save ijokarumawak/bb2e2609af521be0646d to your computer and use it in GitHub Desktop.
@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