CRYPTO NEWS

How to create a mapping where the key is pointing to an array that I can push items into it?

I am trying to create a mapping where the key is an ID and it is pointing to an array of dates. The idea is to enter a date everytime the ID comes to the facility so I can have an array of dates next to the ID I created a struct with a uint VDates and a mapping with a uint key and pointing to the struct but as an array

struct visitDates{     uint VDates; }     mapping (uint => visitDates[]) public dates;  

This is the add date function where I set the key as secret number and push the date entry into the array

function AddVisitDate (uint _date, uint _SecretNum ) public {            dates[_SecretNum].push(visitDates(_date));        }  

The problem is in getVisitDate function where the idea is to pass the secret number and I call the mapping and I need it to return the array containing the dates of visit of that secret number i dont not know how to write this function so if u have any suggestion please suggest

How to create a mapping where the key is pointing to an array that I can push items into it?

Shopping cart
There are no products in the cart!
Continue shopping
0