feat(api): add an endpoint to retrieve the users who have favourited a specific story
This commit is contained in:
		
							parent
							
								
									6b5b01fdd6
								
							
						
					
					
						commit
						f0346ebdbd
					
				
							
								
								
									
										13
									
								
								server/api/story/[id]/lovers.get.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								server/api/story/[id]/lovers.get.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | |||||||
|  | import { User } from "~/models/user"; | ||||||
|  | 
 | ||||||
|  | export default eventHandler(async (ev) => { | ||||||
|  | 	const id = parseInt(getRouterParam(ev, "id") as string); | ||||||
|  | 	let dat = await User.find({ | ||||||
|  | 		"favs.stories": { | ||||||
|  | 			$in: [id], | ||||||
|  | 		}, | ||||||
|  | 	}) | ||||||
|  | 		.select("-auth -email -ipLog -password") | ||||||
|  | 		.exec(); | ||||||
|  | 	return dat.map((a) => a.toObject()); | ||||||
|  | }); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user