I have a struct coming with a list of E-Card details from the database and I want to specify the starting index and the number of user details needed from the struct (limit). For following is a code
Ecards.where(batchId: params[“batchId”])
|> case do
cards →get = Enum.flat_map(get_details, fn string -> for x <- convert_to_int(params["startIndex"])..(convert_to_int(params["startIndex"]) + convert_to_int(params["limit"])) do Enum.fetch(list, x) end end) %{ Status: 0, message: "Cards Listed from Index #{params["startIndex"]} to #{params["limit"]}", cardList: get |> Poison.encode!(), totalCards: Enum.count(get) } end end