Giter VIP home page Giter VIP logo

Comments (6)

tr1v3r avatar tr1v3r commented on May 16, 2024

Actually, there already have constant relationship here, and doc is here :

gen.FieldRelateModel(field.HasMany, "CreditCards", model.CreditCard{}, nil)

Besides, maybe you can describe more clearly what kind of simplification you want.

from gen.

to2false avatar to2false commented on May 16, 2024
  1. Just want to include the model which not from GORM, maybe from mongodb、es.
    The above example, I claim &field.RelateConfig{GORMTag: "-"}
  2. There is no field.Has
    https://github.com/go-gorm/gen/blob/master/field/association.go#L14-L17
    https://github.com/go-gorm/gorm/blob/master/schema/relationship.go#L20
  3. Hope there is an option to mark gorm tag useless like the example above

from gen.

tr1v3r avatar tr1v3r commented on May 16, 2024

OK, got it. The option FieldRelateModel is designed for relationship which can recognized by GORM, which means if you want to add new field in generated model struct which relate to exist struct in your project you should use option FieldNew, ex:

gen.FieldNew("A", "model.A", "")

from gen.

to2false avatar to2false commented on May 16, 2024
gen.FieldNew("A", "model.A", `gorm:"-"`)

The way worked the same as the above example.

But still need to claim fieldTag to disable gorm work, can you provide a way to quickly disable it?

from gen.

tr1v3r avatar tr1v3r commented on May 16, 2024

Actually, the tag gorm:"-" is an additional tag for field your want to build, so we expect it has to be set on your own. And in my opinion, the code gen.FieldNew("A", "model.A", `gorm:"-"`) is concise enough, create another option like gen.FieldNewDisableGORM("A", "model.A") is not necessary.

If you have some reason i don't know can prove the necessity of adding this option, plz let me know.

from gen.

to2false avatar to2false commented on May 16, 2024

That's not much of a reason, just except that there is an option to disable gorm.

It's not too much of a problem for me to be able to customize this

from gen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.