Hi in my dynamic single post page (a page where i load a user post with all comments) i am trying to filter the comments based on the post ID.
I use a database called ’ comments ’ which contains the the name and picture of the user that leaves the comment, and the content of the comment textbox. A field called ’ sourcePostId ’ is used for every comment to identify to what post in particular that comment is related.
As of now (without filtering), when a user writes a comment, the same comment is shown in all the single post dynamic pages…
I tried filtering with this code:
$w.onReady(function () {
wixData.query("comments") //database name
.eq("sourcePostId", ("#text49").text) //respectively field in the database and text label showing post ID
.find()
.then( (results) => {
$w("#repeater1").data = results.items;
})
.catch( (err) => {
let errorMsg=err;
});
});
where text49 is a label that shows that particular post ID (stored successfully in the sourcePostId field of the database).
There are 2 catches, i don’t know if they affect the result.
- I also have another on.Ready section used for login check
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#Like").show();
}
else {
$w("#Like").hide();
}
} );
- the repeater is connected to a dataset querying the database to retrieve the user’s image and full name
I have been stuck on this for the last 2 hours or so, and i cannot come up with a solution…
Any suggestion would be appreciated.
Thank you