Hi again! You may look at my existing code below and see what can be added there which can find ALL of the _owner with its _id (ids) not just one _owner with one _id in one row. So the code should find all of the rows which have the same _owner but different _id (ids) so that it can change all of the owner’s picture and username from different rows in the database.
Hi there! I already figured out the code. It can auto-update the owner’s picture and username without pushing any button, but just by loading the page. Whenever a user visit the page, he/she will see the owner’s updated picture together with the owner’s updated username.
However, for now, it can only find and update one row in a database. I don’t know yet the right code to auto-update all of the pictures from different owners.
$w.onReady(function () {
wixData.query("DatabaseName")
.eq('_owner', wixUsers.currentUser.id)
.find()
.then( (result) => {
let data = result.items[0];
let dataID = data._id;
wixData.query("MemberData")
.eq('_id', wixUsers.currentUser.id)
.find()
.then((results)=>{
let mData = results.items[0];
let items = results.items;
let username = mData.username;
let profPic = mData.profilePicture;
wixData.get("DatabaseName", dataID)
.then((toUpdate)=>{
toUpdate.username = username;
toUpdate.profilePicture = profPic;
wixData.update("DatabaseName", toUpdate)
.then(()=>{
$w('#dataset1').refresh();
})
.catch((err) => {
let errorMsg = err;
});
})
.catch((err) => {
let errorMsg = err;
})
});
});
})