MCPcopy Create free account
hub / github.com/ExtendDB/extenddb / create_table_with_gsi

Function create_table_with_gsi

tests/rust/src/test_base.rs:299–359  ·  view source on GitHub ↗
(
    c: &Client,
    name: &str,
    hash_key: &str,
    hash_type: ScalarAttributeType,
    range_key: Option<&str>,
    range_type: Option<ScalarAttributeType>,
)

Source from the content-addressed store, hash-verified

297}
298
299async fn create_table_with_gsi(
300 c: &Client,
301 name: &str,
302 hash_key: &str,
303 hash_type: ScalarAttributeType,
304 range_key: Option<&str>,
305 range_type: Option<ScalarAttributeType>,
306) {
307 let mut attr_defs = vec![
308 AttributeDefinition::builder()
309 .attribute_name(hash_key)
310 .attribute_type(hash_type.clone())
311 .build()
312 .unwrap(),
313 AttributeDefinition::builder()
314 .attribute_name(GSI_HASH_KEY)
315 .attribute_type(ScalarAttributeType::S)
316 .build()
317 .unwrap(),
318 AttributeDefinition::builder()
319 .attribute_name(GSI_RANGE_KEY)
320 .attribute_type(ScalarAttributeType::S)
321 .build()
322 .unwrap(),
323 ];
324 if let (Some(rk), Some(rt)) = (range_key, range_type.clone()) {
325 attr_defs.push(
326 AttributeDefinition::builder()
327 .attribute_name(rk)
328 .attribute_type(rt)
329 .build()
330 .unwrap(),
331 );
332 }
333
334 let gsi = GlobalSecondaryIndex::builder()
335 .index_name(GSI_NAME)
336 .key_schema(
337 KeySchemaElement::builder()
338 .attribute_name(GSI_HASH_KEY)
339 .key_type(KeyType::Hash)
340 .build()
341 .unwrap(),
342 )
343 .key_schema(
344 KeySchemaElement::builder()
345 .attribute_name(GSI_RANGE_KEY)
346 .key_type(KeyType::Range)
347 .build()
348 .unwrap(),
349 )
350 .projection(
351 Projection::builder()
352 .projection_type(ProjectionType::All)
353 .build(),
354 )
355 .build()
356 .unwrap();

Callers 1

tablesFunction · 0.70

Calls 3

create_table_rawFunction · 0.85
cloneMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected