def find_snakes_for_user(account: Owner) -> List[Snake]: account = find_account_by_email(account.email) # get fresh copy query = Snake.objects(id__in=account.snake_ids).all( ) # find all snake ids in account.snake_ids snakes = list(query) return snakes
def get_snakes_for_user(user_id: bson.ObjectId) -> List[Snake]: owner = Owner.objects(id=user_id).first() snakes = Snake.objects(id__in=owner.snake_ids).all() return list(snakes)
from data.owners import Owner import mongoengine from data.snakes import Snake owner = Owner(name=name, email=email) # owner.id is None owner.save() # owner.id is objectId('whatever object id is') snakes = [snake1, snake2] # ... Snake.objects().insert(snakes)
def get_snakes_for_user(user_id: bson.ObjectId) -> List[Snake]: owner = Owner.objects(id=user_id).first() snakes = Snake.objects(id__in=owner.snake_ids).all() return list(snakes)
def get_snakes_for_user(user_id: bson.ObjectId) -> List[Snake]: owner = Owner.objects(id=user_id).first() # pylint: disable=no-member snakes = Snake.objects(id__in=owner.snake_ids).all() # pylint: disable=no-member return list(snakes)
def get_snakes_for_user(account: Owner): query = Snake.objects(id__in=account.snake_ids).all() snakes = list(query) return snakes