Hello folks,
I find myself once again stumped by multiple references. I’ll try to explain this as succinctly as I can.
Relevant Collections:
- EBTMembers: this is the custom membership database that I created for my website.
- departmentposts: this is the database collecting the data of member-submitted posts that get displayed in a repeater, similar to a newsfeed
- departmentpostlikes: this is the database I use to track which members like which posts. It has two important fields:
-
“post”: this is a reference field, referencing the relevant post from the departmentposts database
-
“likers”: this is a multiple reference field, referencing the EBTMembers who “liked” a given post.
Goal: I want to check to see if the current user is among those who have “liked” each post in the repeater. If yes, I want “fulllike” to expand. If no, I want “emptylike” to expand.
Current code (not working):
$w.onReady( function () {
$w( “#repeater1” ).onItemReady(($item, itemData, index) =>{
wixData.query( “EBTMembers” )
.eq( “_owner” , wixUsers.currentUser.id)
.find()
.then( (results) => {
wixData.isReferenced( “EBTMembers” , “departmentpostlikes” , results.items[ 0 ]._id, itemData.id)
.then( (result3) => {
let isReferenced3 = result3;
if (isReferenced3 === true ) {
$item( "#fulllike" ).expand()
$item( "#emptylike" ).collapse()}
else {
$item( “#fulllike” ).collapse()
$item( “#emptylike” ).expand()
}
})})})})
Any ideas?