trying to pull a single line from a dataset to show in a repeater alone. How? I am trying to allow the repeater to find one piece of information like an email address and then showing the entire entry on that line in the repeater.
I am building a marketplace where people can advertise things for sale and what I would like to create is as follows.
After a user has logged in, on their account pages they will see a page where they can view their “live adverts”.
So what I need help with is the code for this.
I have a dataset that I created called dataset1 this dataset is the information about each item for sale. Within this, is a reference field linking to the Private Members information dataset.
Either in a table of a repeater, I need to show each individual what adverts they have for sale on the site. I thought I could do this by having a text field linked to the Private member dataset showing their login email address at the top of the page and then use this text box as a filter tool for a repeater to find the lines that use this email address. Does that make sense?
Step 1 - TEXT field - linked to PRIVATE MEMBERS DATABASE - displays the login email address from the user.
Step 2 - The repeater uses displayed email address to find it in DATASET B and only displays the lines (advert) that use that email address.
@reynoldselliott21 since you said the email field in collection B is of Type:reference, it’s actually contains the user ID.
So you should query the collection based on the user id and no need to use getEmail at all. something like:
import wixData from 'wix-data';
import wixUsers from 'wix-users';
let currentUser = wixUsers.currentUser, userId = currentUser.id;
$w.onReady(() => {
if(currentUser.loggedIn){
wixData.query("CollectionName")
.eq("email", userId)
.find()
.then(r => {
if(r.items.length > 0){
let userData = r.items[0];
$w("#userInfoTextElement").text = userData.liveAdverts;
}
})
}
})
@reynoldselliott21 No. You haven’t described your database structure, so I built it to show a single value in a single text element. If you want to use a repeater, further description will be needed.
I have a 24 fields, mostly text, then a couple of imagery and some numbers and tags nothing crazy.
I have always just connected through the “link to data” button on a repeater and then coded the use for the repeater. I have a dynamic page already built.
Basically I will duplicate the repeater on the home page to put in this “see your adverts” section but just change the backend code?
It’s rally not clear. You can’t expect us to understand what’s going on from your description.
If it’s only one row, why are you using a repeater at all? It is a single item.
@jonatandor35 Sorry JD I thought you meant is each entry one line or multiple, See attached exactly how the dataset looks, this will obviously grow as more people upload.
Artwork Title- text
Title image - image
Artwork id - text
Type of art - text
Medium - text
Frame - text
Height - number
Width - number
Asking price - number
Coa - text
Condition- text
Photos - media gallery
Type of seller - text
Seller contact number - text
Seller email - text
Style of art - tags
Owner - reference (private member information dataset)
There are multiple rows and this will grow on a daily basis as more sellers submit their artworks to sell.
The repeater will be on a private members page “your current adverts” where they can view the adverts that they have submited to us, like on eBay, view your advert
Like the repeater is on my homepage “featured artworks” i would like to duplicate this but instead of randomising i want it to show their artworks they submitted to us. Sometimes it will be one artwork sometimes it will 10 and so on. I created this form using a template repeater, connecting the display elements to the dataset and button to the artwork dynamic page i created. Then using a code and module that you kindly gave me for the backend to randomize.
Fyi. Please note users do not write data to this database only me using the info they put on forms as it needs to be moderated by me.
@reynoldselliott21 I’d help you, but you really didn’t provide the necessary info.
You posted lots of details about the collection fields but I can’t see there anything regarding the liveAdverts. So it’s just not clear. I can only vaguely guess what you’re trying to do but I don’t want to offer solutions based on guesses.