Duplicate field created when inserting a new record

I’m attempting to insert a new record into a collection that I’ve created. I’ve created a string field in the schema called “userID”. When I run an insert using the code below, a duplicate field named “[userID]” is created. Any insight as to why this is happening?


My simple code:

const toInsert =
{ ‘userID’ : wixUsers.currentUser.id
}

wixData.insert(“CookProfile”, toInsert)
.then( (newuserrecord) => {
let item = newuserrecord;
} )
. catch ( (err) => {
console.assert(err);
} );

Hi,

Welcome to the Wix Code forums.

You need to use the Field Key and not the Field Name .


So, you should use userId , not userID . By using a Field Key that didn’t exist, you actually caused a new field to be added to the collection.

I hope this helps,

Yisrael

Ugh - silly oversight. Thanks Yisrael.