Strange behavior when inserting into a collection

I am writing my own member Forum pages for a client, because they wanted to change the behavior from what the standard Wix forum app does.

Here is a fraction of my code:
let toInsert = {
“threadID”: threadIDString,
“owner”: memberIDString,
“text”: $w(‘#textHTML’).text
};

	wixData.insert("posts", toInsert) 
		.then( (results) => { 
			let item = results; //see item below 
		} ) 
		.catch( (err) => { 
			let errorMsg = err; 
	});  	 

And here is the table after the insert:


The owner column, which contains a reference to “members”, is being updated correctly. On the other hand, you can see that the threadID column, which also contains a reference, has not been changed. Instead there is a column called [threadID] (which I did not create), which is getting updated. Can someone tell me what is going on here please?

Hi Mike,
it is likely that your “threadID” field key is actually “threadId” (with a small ‘d’ at the end).
since the object you insert into the collection has a field key of “threadID” (with a capital ‘D’), the wixcode data system does not find it in the schema.

you can see the field’s key property by clicking the three dots that appear on the right hand side of the field title. then click “manage properties” and see the field’s key.

if it is indeed “threadId”, just change your code to use that and all should be fine.

hope this helps…

Wow … you were right! Thanks a lot!

Solved my problem too. thanks