I’m currently trying to build a solution that can upload a file with some additional information into a collection by using code. So far, I’ve managed to insert a file into the collection and then the additional information on separate rows, but obviously I would like to have everything on the same row.
I have two buttons - one upload button for choosing the file to upload, and a submit button to save everything to the collection. I have used “Connected to data” to save the file to the collection.
The code written thus far is as follows:
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
export function submitButton_click(event) {
let user = wixUsers.currentUser;
let userID = user.id;
let isLoggedIn = user.loggedIn;
let newForm = {
title: “”,
doc: “xx The actual document uploaded”,
docType: “TechForm”,
validated: false ,
userId: userID
}
wixData.save(“TechForm”, newForm);
}
How can I add the document to the “doc” variable above? Or does anyone have a better solution on how to solve this?