go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
36.47k stars 3.9k forks source link

Create View feature is missing, kind of very important #4966

Closed aukgit closed 1 year ago

aukgit commented 2 years ago

Create View feature with Gorm

Describe the feature

  db.
   View.
    CreateOrUpdate().
    Tables(....tables Names ). // strings
    Entities(....tables Names ). // interfaces 
    Select(columNames...). // 5 or 6 columns it is optional
    Join(joinClause).
    Alias(Entity, map[string]string{})
    Where(...., ...).
    ViewName("Give it a name"). // Optional, could come from tables or be placed
    Compile() // finisher method, builder, ends the chain

Motivation

Database views are easily queried on compiled join queries. Currently, the framework doesn't support joins properly. It supports but requires manual work. If we have a view creation option it will reduce the work and query execution and improve the performance

Related Issues

Tags

@riadevatix

Keywords

View, ViewCreation, JoinFeauture, SqlInjection

ghost commented 2 years ago

thanks, It's a good idea, but maybe need to think about how to support it. :stuck_out_tongue:

nafeem-evatix commented 2 years ago

@jinzhu and @ghost This should be a priority

sulthonzh commented 2 years ago

Absolutely cannot wait for these features!

OscBacon commented 1 year ago

Bump: any update on this?

loeffel-io commented 1 year ago

+1

devav2 commented 1 year ago

Please prioritize this for the upcoming releases.

egandro commented 1 year ago

Is there any progress on this?

a631807682 commented 1 year ago

Already implemented in https://github.com/go-gorm/gorm/pull/6097

Connorig commented 5 months ago

Hi, guys. I have a problem when I using gorm to operate pgsql tables. I have about three tables need to be querying, so I created a db view to handle my data. But I cannot use gorm to mapping this view just like I mapping others table models. So Can gorm mapping views like table models? I really want it! Thanks.