[CRUTCH] json tag

This commit is contained in:
royalcat 2023-05-24 13:51:55 +03:00
parent d2338b8f46
commit 013f781b29

View file

@ -66,9 +66,12 @@ func (g baseMethodGenerator) bsonFieldReference(fieldReference spec.FieldReferen
func (g baseMethodGenerator) bsonTagFromField(field code.StructField) (string, error) { func (g baseMethodGenerator) bsonTagFromField(field code.StructField) (string, error) {
bsonTag, ok := field.Tag.Lookup("bson") bsonTag, ok := field.Tag.Lookup("bson")
if !ok {
bsonTag, ok = field.Tag.Lookup("json")
if !ok { if !ok {
return "", NewBsonTagNotFoundError(field.Name) return "", NewBsonTagNotFoundError(field.Name)
} }
}
documentKey := strings.Split(bsonTag, ",")[0] documentKey := strings.Split(bsonTag, ",")[0]
return documentKey, nil return documentKey, nil