Skip to content

Instantly share code, notes, and snippets.

View brfrn169's full-sized avatar

Toshihiro Suzuki brfrn169

View GitHub Profile
@brfrn169
brfrn169 / get_scan_with_index_example.graphql
Created January 25, 2023 01:27
Example of Get/Scan with index (Japanese)
// backテーブルのcountryカラムのセカンダリインデックスを用いたGetクエリ
query BankGetWithIndex {
get_with_index: bank_getWithIndexOn_country(get: {indexKey : {country:"france"}}){
bank {id, region_code, country}
}
}
// backテーブルのregion_codeカラムのセカンダリインデックスを用いたScanクエリ
query BankScanWithIndex {
scan_with_index: bank_scanWithIndexOn_region_code(scan: {indexKey: {region_code: 1}}) {
@brfrn169
brfrn169 / get_scan_with_index_example.graphql
Created January 25, 2023 01:25
Example of Get/Scan with index
// Get query with a secondary index on the “country” column of the “back” table
query BankGetWithIndex {
get_with_index: bank_getWithIndexOn_country(get: {indexKey : {country:"france"}}){
bank {id, region_code, country}
}
}
// Scan query with a secondary index on the “region_code” column of the “bank” table
query BankScanWithIndex {
scan_with_index: bank_scanWithIndexOn_region_code(scan: {indexKey: {region_code: 1}}) {
@brfrn169
brfrn169 / scan_all_with_limit_example.graphql
Created January 25, 2023 01:24
Example of ScanAll with limit in GraphQL
query BankScanAllWithLimit {
scanAll_with_limit: bank_scanAll(scanAll: {limit: 1}){
bank {id, region, country}
}
}
@brfrn169
brfrn169 / scan_all_example.graphql
Created January 25, 2023 01:21
Example of ScanAll in GraphQL
query BankScanAll {
scanAll: bank_scanAll(scanAll: {}){
bank {id, region, country}
}
}
@brfrn169
brfrn169 / spring_data_jdbc_integration_example.java
Created January 25, 2023 01:19
Examples of Spring Data JDBC integration
@Repository
public interface NorthAccountRepository
extends PagingAndSortingRepository<NorthAccount, Integer>,
ScalarDbHelperRepository<NorthAccount> {
@Transactional
default void transferToSouthAccount(
@Nonnull SouthAccountRepository southAccountRepository,
int fromId, int toId, int value) {
@brfrn169
brfrn169 / examples_result.java
Created July 20, 2022 03:44
Examples of how to get column values in Result (Japanese)
Result result = …;
// Boolean型の値を取得
boolean booleanValue = result.getBoolean("<column name>");
// Int型の値を取得
int intValue = result.getInt("<column name>");
// BigInt型の値を取得
long bigIntValue = result.getBigInt("<column name>");
@brfrn169
brfrn169 / builders_example.java
Created July 20, 2022 03:43
Examples of operation builders in Scalar DB (Japanese)
// Getオペレーションの作成
Get get =
Get.newBuilder()
.namespace("ns")
.table("tbl")
.partitionKey(Key.ofInt("c1", 10))
.clusteringKey(Key.of("c2", "aaa", "c3", 100L))
.projections("c1", "c2", "c3", "c4")
.build();
@brfrn169
brfrn169 / example_is_null_of_result.java
Created July 20, 2022 03:33
Example of isNull() in Result
boolean isNull = result.isNull("<column name>");
@brfrn169
brfrn169 / examples_result.java
Created July 20, 2022 03:32
Examples of how to get column values in Result
Result result = …;
// Get a Boolean value of a column
boolean booleanValue = result.getBoolean("<column name>");
// Get an Int value of a column
int intValue = result.getInt("<column name>");
// Get a BigInt value of a column
long bigIntValue = result.getBigInt("<column name>");
@brfrn169
brfrn169 / put_with_null.java
Created July 20, 2022 03:30
Example of Put with NULL
Put put =
Put.newBuilder()
.namespace("ns")
.table("tbl")
.partitionKey(Key.ofInt("c1", 10))
.clusteringKey(Key.of("c2", "aaa", "c3", 100L))
.booleanValue("c1", null)
.intValue("c2", null)
.bigIntValue("c3", null)
.floatValue("c4", null)