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

Comment From: ghost

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

Comment From: nafeem-evatix

@jinzhu and @ghost This should be a priority

Comment From: sulthonzh

Absolutely cannot wait for these features!

Comment From: OscBacon

Bump: any update on this?

Comment From: loeffel-io

+1

Comment From: devav2

Please prioritize this for the upcoming releases.

Comment From: egandro

Is there any progress on this?

Comment From: a631807682

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

Comment From: Connorig

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.