File size: 521 Bytes
252d749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from App.Users.Model import User
from App.Post.Model import Post
import asyncio
from fastapi import HTTPException


async def get_user_and_post(content):
    try:
        #    user = None
        #    post = await Post.objects.get(id=content.postId)
        #    print(post.id)
        user, post = await asyncio.gather(
            *[User.objects.get(id=content.userId), Post.objects.get(id=content.postId)]
        )
    except:
        raise HTTPException(status_code=400, detail="Invalid data")
    return user, post