Dynamoose,保存具有`model`属性的文档

问题描述

我需要使用 Dynamoose 将这样的对象保存到 DynamoDB 文档中。但是,model 值正在转换为 Dynamoose 对象的 JSON 对象......如果有道理的话。

所以如下:

{
  id: '621768c4-05c3-4e21-9120-99f4858266eb',make: 'Yamaha',model: 'R1'
}

model 保存为此,而不是 R1。

{
  "originalName": {
    "S": "cache"
  },"pendingTasks": {
    "L": []
  },"latestTableDetails": {
    "M": {
      "Table": {
        "M": {
          "TableName": {
            "S": "dev-vehicle-lookup-api-cache"
          },"AttributeDeFinitions": {
            "L": [
              {
                "M": {
                  "AttributeName": {
                    "S": "id"
                  },"AttributeType": {
                    "S": "S"
                  }
                }
              }
            ]
          },"CreationDateTime": {
            "M": {}
          },"TableSizeBytes": {
            "N": "2582"
          },"TableArn": {
            "S": "arn:aws:dynamodb:ddblocal:000000000000:table/dev-vehicle-lookup-api-cache"
          },"TableStatus": {
            "S": "ACTIVE"
          },"ItemCount": {
            "N": "1"
          },"ProvisionedThroughput": {
            "M": {
              "WriteCapacityUnits": {
                "N": "0"
              },"LastIncreaseDateTime": {
                "M": {}
              },"NumberOfDecreasesToday": {
                "N": "0"
              },"LastDecreaseDateTime": {
                "M": {}
              },"ReadCapacityUnits": {
                "N": "0"
              }
            }
          },"KeySchema": {
            "L": [
              {
                "M": {
                  "KeyType": {
                    "S": "HASH"
                  },"AttributeName": {
                    "S": "id"
                  }
                }
              }
            ]
          },"BillingModeSummary": {
            "M": {
              "BillingMode": {
                "S": "PAY_PER_REQUEST"
              },"LastUpdatetoPayPerRequestDateTime": {
                "M": {}
              }
            }
          }
        }
      }
    }
  },"ready": {
    "BOOL": true
  },"methods": {
    "M": {
      "document": {
        "M": {}
      }
    }
  },"schemas": {
    "L": [
      {
        "M": {
          "settings": {
            "M": {
              "saveUnkNown": {
                "L": [
                  {
                    "S": "**"
                  }
                ]
              },"timestamps": {
                "M": {
                  "createdAt": {
                    "S": "createdAt"
                  },"updatedAt": {
                    "S": "updatedAt"
                  }
                }
              }
            }
          },"getIndexrangeKeyAttributes": {
            "M": {}
          },"getIndexes": {
            "M": {}
          },"requiredCheck": {
            "M": {}
          },"schemaObject": {
            "M": {
              "id": {
                "M": {
                  "required": {
                    "BOOL": true
                  }
                }
              }
            }
          },"getIndexAttributes": {
            "M": {}
          }
        }
      }
    ]
  },"options": {
    "M": {
      "populate": {
        "BOOL": false
      },"waitForActive": {
        "M": {
          "enabled": {
            "BOOL": true
          },"check": {
            "M": {
              "timeout": {
                "N": "180000"
              },"frequency": {
                "N": "1000"
              }
            }
          }
        }
      },"prefix": {
        "S": "dev-vehicle-lookup-api-"
      },"create": {
        "BOOL": false
      },"update": {
        "BOOL": false
      },"throughput": {
        "M": {
          "write": {
            "N": "1"
          },"read": {
            "N": "1"
          }
        }
      },"suffix": {
        "S": ""
      }
    }
  },"name": {
    "S": "dev-vehicle-lookup-api-cache"
  },"serializer": {
    "M": {
      "default": {
        "M": {}
      }
    }
  },"alreadyCreated": {
    "BOOL": false
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)