optionnal vars failed

This commit is contained in:
mr 2024-07-31 11:47:47 +02:00
parent 1ff4cb08d1
commit 2795c924f7
3 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type AbstractResource struct {
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
Price string `json:"price,omitempty" bson:"price,omitempty"`
Currency string `json:"price,omitempty" bson:"price,omitempty"`
License string `json:"license,omitempty" bson:"license,omitempty"`
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"`
//Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`

View File

@ -45,7 +45,7 @@ func (dma *AbstractAccessor) SetLogger(t DataType) {
func (wfa *AbstractAccessor) GenericStoreOne(data DBObject, accessor Accessor) (DBObject, int, error) {
data.GenerateID()
if cursor, _, _ := accessor.Search(data.GetName(), []string{"abstractresource.abstractobject.name", "abstractobject.name"}...); len(cursor) > 0 {
if cursor, _, _ := accessor.Search(data.GetName(), "abstractresource.abstractobject.name", "abstractobject.name"); len(cursor) > 0 {
return nil, 409, errors.New(accessor.GetType() + " with name " + data.GetName() + " already exists")
}
err := validate.Struct(data)

8
models/utils/common.go Normal file
View File

@ -0,0 +1,8 @@
package utils
/*
type Price struct {
Price float64 `json:"price,omitempty" bson:"price,omitempty"`
Currency string `json:"currency,omitempty" bson:"currency,omitempty"`
}
*/