File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
crates/key-value-azure/src Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,18 @@ impl Store for AzureCosmosStore {
190
190
}
191
191
192
192
async fn exists ( & self , key : & str ) -> Result < bool , Error > {
193
- Ok ( self . get_entity :: < Key > ( key) . await ?. is_some ( ) )
193
+ let mut stream = self
194
+ . client
195
+ . query_documents ( Query :: new ( self . get_id_query ( key) ) )
196
+ . query_cross_partition ( true )
197
+ . max_item_count ( 1 )
198
+ . into_stream :: < Key > ( ) ;
199
+
200
+ match stream. next ( ) . await {
201
+ Some ( Ok ( res) ) => Ok ( !res. results . is_empty ( ) ) ,
202
+ Some ( Err ( e) ) => Err ( log_error ( e) ) ,
203
+ None => Ok ( false ) ,
204
+ }
194
205
}
195
206
196
207
async fn get_keys ( & self ) -> Result < Vec < String > , Error > {
@@ -446,8 +457,14 @@ impl AzureCosmosStore {
446
457
query
447
458
}
448
459
460
+ fn get_id_query ( & self , key : & str ) -> String {
461
+ let mut query = format ! ( "SELECT c.id, c.store_id FROM c WHERE c.id='{key}'" ) ;
462
+ self . append_store_id ( & mut query, true ) ;
463
+ query
464
+ }
465
+
449
466
fn get_keys_query ( & self ) -> String {
450
- let mut query = "SELECT * FROM c" . to_owned ( ) ;
467
+ let mut query = "SELECT c.id, c.store_id FROM c" . to_owned ( ) ;
451
468
self . append_store_id ( & mut query, false ) ;
452
469
query
453
470
}
You can’t perform that action at this time.
0 commit comments