Hello Everyone,
I am not a developer and do not know much and hence the reason I started with Wix back then. Having said that, I am so stoked about being able to add databases that I am giving it a try, but now I am stuck and hope that someone can assist me.
I have got a few collections for displaying TV Series Connecting my TVShows collection to a dataset on the Home page and displaying the TV Shows in a repeater, you can click the ‘View’ button on the TV show that will take you to a dynamic page according to title.
On the dynamic page I have another dataset connected to the TVShows collection with two text boxes:
#text52 = The number of seasons
#text63 = The TV show ID (ShowID in TVShows collection)
I want to do a query on my TVSeasons collection to count the the number of times the TV Show ID (ShowID) is showing.
Below see my collections and query:
TVShows:
ShowID(Primary key)>Title>Image>Description>TVSeason (Reference Field to TVSeasons - multi)
Field Key:
ShowID = showID
Title = title
Description = description
Seasons = seasons
TVSeason = tvSeason
TVSeasons:
Title(Primary key)>TVShows-2 (Reference TVShows)>SeasonNumber>Episode(Reference field to Episodes- multi)
Field Key:
Title=title
TVShows-2 = TVShows-2
Episode = tvepisode
EpisodesTitle:
Title(Primary key)>TVSeasons (Reference from TVSeasons)>Season>EpisodeNumber>EpisodeTitle>Description
Field Key:
Title = title
TVSeasons = TVSeasons
season = season_title
EpisodeNumber = episodeNumber
EpisodeTitle = episode_title
Description = description_episode
My query:
import wixData from ‘wix-data’;
// …
$w.onReady(function () {
//TODO: write your page related code here…
let value1 = $w(“#text63”).text;
wixData.query(“TVSeasons”)
.contains(“title”,value1)
.count()
.then( (num) => {
let numberOfItems = num;
$w(“#text52”).text = num.toLocaleString()
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
});
If I replace .contains(“title”, value1) with .contains(“title”, “ShowID”) - it counts correctly but setting value1 to #text63 and use that in the query (remembering that #text63 is the ShowID displayed in a text box on-page), it returns 0.
.contains() according to the Wix code help can also make use of a reference - I have tried every property and reference field I can think of but nothing)
I then tried to make use of .include() But .include(TVShows-2) or any other include I could not get it to work to use the ShowID in the query
Please help this noob!