I appreciate anyone who can chime in here. I have spent many hours on this researching and trying different things. I am pretty new to coding in general so I appreciate patient and kind responses.
I am transitioning from a 20+ year old series of databases and importing the data into wix/corvid. The databases I am dealing with have a few thousand records each.
The goal here is to import the data and create reference fields as well as use the automatically generated _id created in corvid.
My ideal scenario would for this to be done automatically once importing the data. I was able to do what I was wanting through using a hook “afterQuery” event on the database.
The problem with this is that the data is not permanent and chews up a lot of resources every time you query the database. Please see my code below where I am reaching out to find the ID to a specific parcel and assigning that ID to a reference field in my Taxes database.
export async function Taxes_afterQuery(item, context) {
let parcel = item.parcelNumber;
const NewID = await wixData.query("ParcelNumbers")
.eq("parcelNumber", parcel)
.find()
let NewParcelID = NewID.items[0]._id;
//console.log(NewParcelID);
item.idParcel = NewParcelID;
return await item;
}
Is there a better way to do this so the data is permanent. I only need to do this after the initial import. From that point on as I add data I can take care of it correctly.
I hope this makes sense to someone.