首先,我尝试了过去 stackoverflow 答案中的解决方案,这些答案的问题与我的问题相关,但没有任何效果,这就是为什么我将其作为一个单独的问题提出。
我在 golang 中有两个结构
type otherPayments struct {
DebitTo int `json:"debit_To" binding:"required"`
CreditFrom int `json:"credit_from" binding:"required"`
OverallType string `json:"overall_type" binding:"required"`
}
type advanceAndRoomPayment struct {
PmID int `json:"pm_id" binding:"required"` //Payment method id
PmName string `json:"pm_name" binding:"required"` //Payment method name
DebitTo int `json:"debit_To" binding:"required"` //The ledger to debit from
CreditFrom int `json:"credit_from" binding:"required"` //The ledger to credit from
OverallType string `json:"overall_type" binding:"required"` //Overall transaction type
}
我的postgresql 表中有5SQL 列booking_settings
initial
列,类型 = otherPayments
,JSONB
cancellation
, 输入 = otherPayments
,JSONB
updation
, 输入 = otherPayments
,JSONB
advance_payment
输入 = advanceAndRoomPayment
,JSONB []
room_payment
, 输入 = advanceAndRoomPayment
,JSONB []
查询SELECT
如下
SELECT initial, cancellation, updation advance_payment, room_payment FROM booking_settings WHERE hotel_id = $1
我使用的 sql 包是https://jmoiron.github.io/sqlx/
我正在尝试将上面的列扫描到它们适当的结构变量中,到目前为止我只能设法扫描initial, cancellation and updation
而不是JSONB []
advance_payment and room_payment
非常感谢任何帮助,谢谢
慕虎7371278
相关分类