feat: Added chapter 5
This commit is contained in:
		
							
								
								
									
										18
									
								
								sql/queries/chirps.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								sql/queries/chirps.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
-- name: CreateChirp :one
 | 
			
		||||
INSERT INTO chirps (id, created_at, updated_at, body, user_id)
 | 
			
		||||
VALUES (
 | 
			
		||||
    gen_random_uuid(),
 | 
			
		||||
    NOW(),
 | 
			
		||||
    NOW(),
 | 
			
		||||
    $1,
 | 
			
		||||
    $2
 | 
			
		||||
)
 | 
			
		||||
RETURNING *;
 | 
			
		||||
 | 
			
		||||
-- name: GetChirps :many
 | 
			
		||||
SELECT * FROM chirps
 | 
			
		||||
ORDER BY created_at ASC;
 | 
			
		||||
 | 
			
		||||
-- name: GetChirp :one
 | 
			
		||||
SELECT * FROM chirps
 | 
			
		||||
WHERE chirps.id = $1;
 | 
			
		||||
							
								
								
									
										13
									
								
								sql/queries/users.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								sql/queries/users.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
-- name: CreateUser :one
 | 
			
		||||
INSERT INTO users (id, created_at, updated_at, email)
 | 
			
		||||
VALUES (
 | 
			
		||||
    gen_random_uuid(),
 | 
			
		||||
    NOW(),
 | 
			
		||||
    NOW(),
 | 
			
		||||
    $1
 | 
			
		||||
)
 | 
			
		||||
RETURNING *;
 | 
			
		||||
 | 
			
		||||
-- name: DeleteUser :one
 | 
			
		||||
DELETE FROM users
 | 
			
		||||
RETURNING *;
 | 
			
		||||
		Reference in New Issue
	
	Block a user