22
33import java .io .IOException ;
44import java .util .Collection ;
5+ import java .util .Optional ;
56import java .util .concurrent .CompletableFuture ;
67import java .util .function .Function ;
78
89import io .weaviate .client6 .v1 .api .collections .ObjectMetadata ;
910import io .weaviate .client6 .v1 .api .collections .WeaviateObject ;
11+ import io .weaviate .client6 .v1 .api .collections .query .WeaviateQueryClientAsync ;
1012import io .weaviate .client6 .v1 .internal .ObjectBuilder ;
1113import io .weaviate .client6 .v1 .internal .orm .CollectionDescriptor ;
1214import io .weaviate .client6 .v1 .internal .rest .RestTransport ;
@@ -15,9 +17,13 @@ public class WeaviateDataClientAsync<T> {
1517 private final RestTransport restTransport ;
1618 private final CollectionDescriptor <T > collectionDescriptor ;
1719
18- public WeaviateDataClientAsync (CollectionDescriptor <T > collectionDescriptor , RestTransport restTransport ) {
20+ private final WeaviateQueryClientAsync <T > query ;
21+
22+ public WeaviateDataClientAsync (CollectionDescriptor <T > collectionDescriptor , RestTransport restTransport ,
23+ WeaviateQueryClientAsync <T > query ) {
1924 this .restTransport = restTransport ;
2025 this .collectionDescriptor = collectionDescriptor ;
26+ this .query = query ;
2127 }
2228
2329 public CompletableFuture <WeaviateObject <T , Object , ObjectMetadata >> insert (T properties ) throws IOException {
@@ -35,6 +41,10 @@ public CompletableFuture<WeaviateObject<T, Object, ObjectMetadata>> insert(Inser
3541 return this .restTransport .performRequestAsync (request , InsertObjectRequest .endpoint (collectionDescriptor ));
3642 }
3743
44+ public CompletableFuture <Boolean > exists (String uuid ) {
45+ return this .query .byId (uuid ).thenApply (Optional ::isPresent );
46+ }
47+
3848 public CompletableFuture <Void > delete (String uuid ) {
3949 return this .restTransport .performRequestAsync (new DeleteObjectRequest (collectionDescriptor .name (), uuid ),
4050 DeleteObjectRequest ._ENDPOINT );
0 commit comments