Creating ratings collection from scratch...

I have been trying to create my own ratings collection and it’s kind of working but it won’t allow multiple submissions for the same item.

I assume that you probably can’t have an item duplicated in a collection which is why this is happening. But I can’t think of another way to do what I’m trying to do…

I have a repeater connected to a dataset showing the Name (collection field) of an artist. The repeater also contains the ratings elements I have put together from scratch (Editor X doesn’t seem to have a ratings input yet). I want an item to be added to the artistRatings collection which contains the artists name along with the rest of the item’s data and also add the rating number into the rating field.

Currently this process works, however, when I try to submit a rating for the same artist from another test account it doesn’t work. In preview, it shows an error message saying the item id already exists.

So I need to find out how to either insert multiple ratings for one item or be able to insert the item with all it’s data multiple times as a new item.

I will show the code I’m using below. Would really appreciate any ideas/help :slight_smile:

//-------------Submit Ratings-------------//

// Submit one star rating.
async function submitOneStar(artistRating, index) {

    artistRating.rating = "1";
    wixData.insert("artistRatings", artistRating)
        .then((results) => {})
        .catch((err) => {
 let errorMsg = err;
        });

}
// Submit two star rating.
async function submitTwoStar(artistRating, index) {

    artistRating.rating = "2";
    wixData.insert("artistRatings", artistRating)
        .then((results) => {})
        .catch((err) => {
 let errorMsg = err;
        });

}
// Submit three star rating.
async function submitThreeStar(artistRating, index) {

    artistRating.rating = "3";
    wixData.insert("artistRatings", artistRating)
        .then((results) => {})
        .catch((err) => {
 let errorMsg = err;
        });

}
// Submit four star rating.
async function submitFourStar(artistRating, index) {

    artistRating.rating = "4";
    wixData.insert("artistRatings", artistRating)
        .then((results) => {})
        .catch((err) => {
 let errorMsg = err;
        });

}
// Submit five star rating.
async function submitFiveStar(artistRating, index) {

    artistRating.rating = "5";
    wixData.insert("artistRatings", artistRating)
        .then((results) => {})
        .catch((err) => {
 let errorMsg = err;
        });

}

The Ratings by User example should give you a good start.

Thank you. I’ve had a look but it seems that example uses the pre-existing ratings input element. I have had to create my own as I’m using editor x and I just need to find out how to insert multiple versions of the same item into a data collection