データに自動で生成時間や更新時間をつけたいので,レファレンス通りに以下を追加しました.
Created time.Time orm:"auto_now_add;type(datetime)"
Updated time.Time orm:"auto_now;type(datetime)"
このあと,swaggerから適当にデータを投げると,
curl -X POST "http://localhost:8080/test_db/tv_program/" -H "accept: application/json" -H "content-type: application/json" -d "{ "Content": "string", "Created": "string", "Id": 0, "Imageurl": "string", "Title": "string", "Updated": "string", "Url": "string"}"
以下のように,いくつかの項目が自動的に欠落してしまうのです.
response
{
"Id": 1,
"Title": "",
"Content": "string",
"Imageurl": "",
"Url": "",
"Created": "2019-08-11T04:39:58.433010857Z",
"Updated": "2019-08-11T04:39:58.433012373Z"
}
なんとかなりませんか?
ひとまずは,auto宣言をやめて,フォームの方からデータをポストしようかと思います.
あなたの回答
tips
プレビュー