use of com.google.firestore.v1.StructuredQuery.FieldReference in project beam by apache.
the class FirestoreTestingHelper method listDocumentsViaQuery.
Stream<String> listDocumentsViaQuery(String collectionPath) {
int index = collectionPath.lastIndexOf('/');
String parent = collectionPath.substring(0, index);
String collectionId = collectionPath.substring(index + 1);
FieldReference nameField = FieldReference.newBuilder().setFieldPath("__name__").build();
RunQueryRequest rqr = RunQueryRequest.newBuilder().setParent(parent).setStructuredQuery(StructuredQuery.newBuilder().addFrom(CollectionSelector.newBuilder().setCollectionId(collectionId)).addOrderBy(Order.newBuilder().setField(nameField).setDirection(Direction.ASCENDING).build()).setSelect(Projection.newBuilder().addFields(nameField).build())).build();
return StreamSupport.stream(rpc.runQueryCallable().call(rqr).spliterator(), false).filter(RunQueryResponse::hasDocument).map(RunQueryResponse::getDocument).map(Document::getName);
}
Aggregations