- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
DynamoDB filter on a nested field value using Golang
Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: https://www.instagram.com/ky.emrah
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!DynamoDB filter on a nested field value using Golang
Table name: MyTable
Attribute name: data
Keyword to filter: rally
MyTable
data
rally
Given an example value, how do I filter items where the attributes.label array contains a rally?
attributes.label
rally
{
"type": {
"S": "play"
},
"attributes": {
"M": {
"term": {
"S": "end_term"
},
"label": {
"L": [
{
"S": "all_players"
},
{
"S": "rally"
},
{
"S": "race"
}
]
},
"currency": {
"S": "USD"
}
}
},
"id": {
"S": "a752d2"
}
}
{
"type": {
"S": "play"
},
"attributes": {
"M": {
"term": {
"S": "end_term"
},
"label": {
"L": [
{
"S": "all_players"
},
{
"S": "rally"
},
{
"S": "race"
}
]
},
"currency": {
"S": "USD"
}
}
},
"id": {
"S": "a752d2"
}
}
I used example below but it always returns 0 items.
0
input := &dynamodb.ScanInput{
TableName: aws.String("MyTable"),
FilterExpression: aws.String("contains(#path, :keyword)"),
ExpressionAttributeNames: map[string]string{
"#path": "attributes.label",
},
ExpressionAttributeValues: map[string]types.AttributeValue{
":keyword": &types.AttributeValueMemberS{Value: "rally"},
},
}
result, err := c.client.Scan(context.TODO(), input)
if err != nil {
log.Fatalf("failed to scan items: %v", err)
}
fmt.Println(" Result", len(result.Items))
for i, item := range result.Items {
var data map[string]interface{}
err := json.Unmarshal([]byte(item["data"].(*types.AttributeValueMemberS).Value), &data)
if err != nil {
log.Printf("failed to unmarshal item: %v", item)
continue
}
fmt.Printf(" Item (%d): %+v", i, data)
}
input := &dynamodb.ScanInput{
TableName: aws.String("MyTable"),
FilterExpression: aws.String("contains(#path, :keyword)"),
ExpressionAttributeNames: map[string]string{
"#path": "attributes.label",
},
ExpressionAttributeValues: map[string]types.AttributeValue{
":keyword": &types.AttributeValueMemberS{Value: "rally"},
},
}
result, err := c.client.Scan(context.TODO(), input)
if err != nil {
log.Fatalf("failed to scan items: %v", err)
}
fmt.Println(" Result", len(result.Items))
for i, item := range result.Items {
var data map[string]interface{}
err := json.Unmarshal([]byte(item["data"].(*types.AttributeValueMemberS).Value), &data)
if err != nil {
log.Printf("failed to unmarshal item: %v", item)
continue
}
fmt.Printf(" Item (%d): %+v", i, data)
}
Tags: amazon-web-services,go,amazon-dynamodbSource of the question:
https://stackoverflow.com/questions/79007384
Question and source license information:
https://meta.stackexchange.com/help/licensing
https://stackoverflow.com/
Видео DynamoDB filter on a nested field value using Golang канала Emrah KAYA
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!DynamoDB filter on a nested field value using Golang
Table name: MyTable
Attribute name: data
Keyword to filter: rally
MyTable
data
rally
Given an example value, how do I filter items where the attributes.label array contains a rally?
attributes.label
rally
{
"type": {
"S": "play"
},
"attributes": {
"M": {
"term": {
"S": "end_term"
},
"label": {
"L": [
{
"S": "all_players"
},
{
"S": "rally"
},
{
"S": "race"
}
]
},
"currency": {
"S": "USD"
}
}
},
"id": {
"S": "a752d2"
}
}
{
"type": {
"S": "play"
},
"attributes": {
"M": {
"term": {
"S": "end_term"
},
"label": {
"L": [
{
"S": "all_players"
},
{
"S": "rally"
},
{
"S": "race"
}
]
},
"currency": {
"S": "USD"
}
}
},
"id": {
"S": "a752d2"
}
}
I used example below but it always returns 0 items.
0
input := &dynamodb.ScanInput{
TableName: aws.String("MyTable"),
FilterExpression: aws.String("contains(#path, :keyword)"),
ExpressionAttributeNames: map[string]string{
"#path": "attributes.label",
},
ExpressionAttributeValues: map[string]types.AttributeValue{
":keyword": &types.AttributeValueMemberS{Value: "rally"},
},
}
result, err := c.client.Scan(context.TODO(), input)
if err != nil {
log.Fatalf("failed to scan items: %v", err)
}
fmt.Println(" Result", len(result.Items))
for i, item := range result.Items {
var data map[string]interface{}
err := json.Unmarshal([]byte(item["data"].(*types.AttributeValueMemberS).Value), &data)
if err != nil {
log.Printf("failed to unmarshal item: %v", item)
continue
}
fmt.Printf(" Item (%d): %+v", i, data)
}
input := &dynamodb.ScanInput{
TableName: aws.String("MyTable"),
FilterExpression: aws.String("contains(#path, :keyword)"),
ExpressionAttributeNames: map[string]string{
"#path": "attributes.label",
},
ExpressionAttributeValues: map[string]types.AttributeValue{
":keyword": &types.AttributeValueMemberS{Value: "rally"},
},
}
result, err := c.client.Scan(context.TODO(), input)
if err != nil {
log.Fatalf("failed to scan items: %v", err)
}
fmt.Println(" Result", len(result.Items))
for i, item := range result.Items {
var data map[string]interface{}
err := json.Unmarshal([]byte(item["data"].(*types.AttributeValueMemberS).Value), &data)
if err != nil {
log.Printf("failed to unmarshal item: %v", item)
continue
}
fmt.Printf(" Item (%d): %+v", i, data)
}
Tags: amazon-web-services,go,amazon-dynamodbSource of the question:
https://stackoverflow.com/questions/79007384
Question and source license information:
https://meta.stackexchange.com/help/licensing
https://stackoverflow.com/
Видео DynamoDB filter on a nested field value using Golang канала Emrah KAYA
Комментарии отсутствуют
Информация о видео
23 ноября 2024 г. 18:35:05
00:01:12
Другие видео канала
