I have a one time need to insert a record on my members table in the 2 linked columns (which are R/O). My code:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
$w.onReady( function () {
});
export function button3_click(event, $w) {
let userId = wixUsers.currentUser.id;
console.log(userId);
let toInsert = {
“link-Members-_id”: userId,
“link-Members-Update-_id”: userId
};
wixData.insert("Members", toInsert)
.then( (results) => {
let item = results;
console.log(item);
} )
. catch ( (err) => {
let errorMsg = err;
console.log(errorMsg);
} );
}
My results from console.log:
c4b32d17-bddc-4d74-8176-464cc2fdffdd
{“link-Members-_id”:“/Members/17b376aa-b398-439f-82da-63a2a122d4e0”,“link-Members-Update-_id”:“/Members/Update/17b376aa-b398-439f-82da-63a2a122d4e0”,“_owner”:“c4b32d17-bddc-4d74-8176-464cc2fdffdd”,“_id”:“17b376aa-b398-439f-82da-63a2a122d4e0”,“_createdDate”:“2018-06-13T15:34:18.854Z”,“_updatedDate”:“2018-06-13T15:34:18.854Z”}
The first line (c4b…) is from me just logging the userId value. The rest is from printing the results of the insert…
Why are the values for userId different? How can I insert with the proper userId?