Hello,
I am trying to modify a collection using the code below to add an element. The variables “name” and “file” are appropriately defined in code before the let statement. The problem is that the collection creates new fields named like “[Title]” and “[Image]” and does not recognize the existing fields in the collection, that have the same name. II have tried all the options like naming the fields in the “toInsert” variable as “Title” or ‘Title’ and such, but nothing helps. You should know that the fields Title and Image are not the only one in the collection, but I have commented out the others for brevity. It must be something very simple I am missing because I could not find any other user with the same problem on the forum. Thanks for the help.
let toInsert = {
Title: name, // not matter how I define the field here (like “Title” or ‘title’),
// the collection “abstract” below will always create a new field named [Title]
Image: file.url,
};
wixData.insert("abstract", toInsert)
.then((results) => {
let item = results; //see item below
console.log("done writing in database");
})
.catch((err) => {
let errorMsg = err;
});