user stuff started
This commit is contained in:
		
							parent
							
								
									7e8e1e1f07
								
							
						
					
					
						commit
						ba6765415b
					
				
					 2 changed files with 32 additions and 6 deletions
				
			
		
							
								
								
									
										32
									
								
								server/internal/database/queries-user.sql
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								server/internal/database/queries-user.sql
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
-- CreateUser :exec
 | 
			
		||||
INSERT INTO users (
 | 
			
		||||
  user_name, display_name, pw_hash, email_address
 | 
			
		||||
) VALUES ($1, $2, $3, $4);
 | 
			
		||||
 | 
			
		||||
-- DeleteUser :exec
 | 
			
		||||
DELETE FROM users
 | 
			
		||||
WHERE id = $1;
 | 
			
		||||
 | 
			
		||||
-- UpdateUserPW :exec
 | 
			
		||||
UPDATE users 
 | 
			
		||||
SET pw_hash = $2
 | 
			
		||||
WHERE id = $1;
 | 
			
		||||
 | 
			
		||||
-- UpdateUserName :exec
 | 
			
		||||
UPDATE users
 | 
			
		||||
SET user_name = $2
 | 
			
		||||
WHERE id = $1;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- UpdateUserDisplayName :exec
 | 
			
		||||
UPDATE users
 | 
			
		||||
SET display_name = $2
 | 
			
		||||
WHERE id = $1;
 | 
			
		||||
 | 
			
		||||
-- GetUser :one
 | 
			
		||||
SELECT * FROM users 
 | 
			
		||||
WHERE id = $1;
 | 
			
		||||
 | 
			
		||||
-- GetUserByName :one
 | 
			
		||||
SELECT * FROM users
 | 
			
		||||
WHERE user_name = $1;
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,2 @@
 | 
			
		|||
package database
 | 
			
		||||
 | 
			
		||||
type User struct {
 | 
			
		||||
	Id     int64
 | 
			
		||||
	Name   string `xorm:"not null unique"`
 | 
			
		||||
	PwHash string //Password hash
 | 
			
		||||
	Role   int64  `xorm:"default 0"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue