def users_user_id_get(userId): """ method to retrieve user using user id """ try: user = User.get(userId) buildings = Building.scan(ownerId__eq=userId) #add ownedBuildings to the user object without having it reflect in the model user.__dict__["attribute_values"].update({"ownedBuildings": []}) #look at all the builings the user owns for building in buildings: #add the builings to the ownedBuildings list user.__dict__["attribute_values"]["ownedBuildings"].append(building.attribute_values["id"]) except Exception as inst: print(inst.args) return 'User with id=%s does not exist.' % (userId) return user.attribute_values
def users_user_id_get(userId): """ method to retrieve user using user id """ try: user = User.get(userId) buildings = Building.scan(ownerId__eq=userId) #add ownedBuildings to the user object without having it reflect in the model user.__dict__["attribute_values"].update({"ownedBuildings": []}) #look at all the builings the user owns for building in buildings: #add the builings to the ownedBuildings list user.__dict__["attribute_values"]["ownedBuildings"].append( building.attribute_values["id"]) except Exception as inst: print(inst.args) return 'User with id=%s does not exist.' % (userId) return user.attribute_values
def buildings_get() -> str: resultList = [] for item in Building.scan(): resultList.append(item.attribute_values) return resultList
def buildings_delete() -> str: temp = [] for item in Building.scan(): temp.append(item.delete()) return "%s items deleted." % len(temp)
def buildings_get(): """ method to get all buildings """ resultlist = [] for item in Building.scan(): resultlist.append(item.attribute_values) return resultlist
def buildings_delete(): """ method to delete all buildings """ temp = [] for item in Building.scan(): temp.append(item.delete()) return "%s items deleted." % len(temp)