Create table method
This commit is contained in:
		
							parent
							
								
									1ddc8e3984
								
							
						
					
					
						commit
						70315e8fed
					
				
							
								
								
									
										6
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.go
									
									
									
									
									
								
							| @ -79,3 +79,9 @@ func (s *DB) Exec(sql string) (orm *Orm) { | ||||
| 	orm.Exec(sql) | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func (s *DB) CreateTable(value interface{}) (orm *Orm) { | ||||
| 	orm = s.buildORM() | ||||
| 	orm.CreateTable(value) | ||||
| 	return | ||||
| } | ||||
|  | ||||
							
								
								
									
										4
									
								
								orm.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								orm.go
									
									
									
									
									
								
							| @ -126,3 +126,7 @@ func (s *Orm) Or(querystring interface{}, args ...interface{}) *Orm { | ||||
| func (s *Orm) Not(querystring interface{}, args ...interface{}) *Orm { | ||||
| 	return s | ||||
| } | ||||
| 
 | ||||
| func (s *Orm) CreateTable(value interface{}) *Orm { | ||||
| 	return s | ||||
| } | ||||
|  | ||||
| @ -7,7 +7,7 @@ type User struct { | ||||
| } | ||||
| 
 | ||||
| func getDB() DB { | ||||
| 	db, _ := Open("postgres", "user=gorm dbname=gorm  sslmode=disable") | ||||
| 	db, _ := Open("postgres", "user=gorm dbname=gorm sslmode=disable") | ||||
| 	return db | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										11
									
								
								sql.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								sql.go
									
									
									
									
									
								
							| @ -17,6 +17,8 @@ func (s *Orm) explain(value interface{}, operation string) *Orm { | ||||
| 		s.deleteSql(value) | ||||
| 	case "Query": | ||||
| 		s.querySql(value) | ||||
| 	case "CreateTable": | ||||
| 		s.createTableSql(value) | ||||
| 	} | ||||
| 	return s | ||||
| } | ||||
| @ -101,3 +103,12 @@ func (s *Orm) whereSql() (sql string) { | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func (s *Orm) createTableSql(value interface{}) { | ||||
| 	s.Sql = fmt.Sprintf( | ||||
| 		"CREATE TABLE \"%v\" (%v)", | ||||
| 		s.TableName, | ||||
| 		"", | ||||
| 	) | ||||
| 	return | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jinzhu
						Jinzhu