Problems with Code to Perform Search on Category

Dear Community:

I am trying to create a search query for my Data Collection. Below is the code I entered. But nothing is happening when I click the button. Can you please advise where I am missing a step in the code? Also, on line 28, I am getting an error code: parsing error unexpected token “label” — what does that mean? I do not have any Java Script experience so this is my first attempt at learning. Thank you for your patience.

:camera:
Thank you.
import wixData from ‘wix-data’;
export function button1_click(event, $w) {
//// Runs a query on the “CoachDirectory” collection
wixData.query(‘CoachDirectory’)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(‘name’, $w(‘#input1’).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(‘#table1’).rows = res.items;
});
}
$w.onReady( function () {
$w(“#table1”).columns = [
{
“id”: “col1”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “newField”,
“label”: “Coach Pic”, // The column header
“width”: 100, // Column width
“visible”: true , // Column visibility
“type”: “image”, // Data type for the column
},
{
“id”: “col2”,
“dataPath”: “coachFirstName”,“coachLastName”
“label”: “Coach Name”
“width”: 100,
“visible”: true ,
“type”: “string”,
},
{
“id”: “col3”,
“dataPath”: “specialty”
“label”: “Coaching Specialty”,
“width”: 100,
“visible”: true ,
“type”: “string”,
},
{
“id”: “col4”,
“dataPath”: “availability”
“label”: “Availability”,
“width”: 100,
“visible”: true ,
“type”: “string”,
}];
});

In this line you have a couple of problems:
“dataPath”: “coachFirstName”,“coachLastName”

The line doesn’t end in a comma and the next line can’t determine what “label” is. Also, you have two data items (coachFirstName and coachLastName). Is that the dataPath? What do you want for the dataPath? What are you trying to do here?

I wanted to add both fields, meaning, I want to generate the first and last name of the contractor/coach. If that is not possible, I will just do the first name. So, it sounds like I just need to add the comma at the end and then remove the last name datapath/field?

I forgot to ask: is that the only issue? I made the corrections, but the search is still not working. I typed the word in the column associated with Speciality and nothing happens.

import wixData from ‘wix-data’;
export function button1_click(event, $w) {
//// Runs a query on the “CoachDirectory” collection
wixData.query(‘CoachDirectory’)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(‘specialty’, $w(‘#input1’).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(‘#table1’).rows = res.items;
});
}
$w.onReady( function () {
$w(“#table1”).columns = [
{
“id”: “col1”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “newField”,
“label”: “Coach Pic”, // The column header
“width”: 100, // Column width
“visible”: true , // Column visibility
“type”: “image”, // Data type for the column
},
{
“id”: “col2”,
“dataPath”: “coachFirstName”,
“label”: “Coach Name”,
“width”: 100,
“visible”: true ,
“type”: “string”,
},
{
“id”: “col3”,
“dataPath”: “specialty”,
“label”: “Coaching Specialty”,
“width”: 100,
“visible”: true ,
“type”: “string”,
},
{
“id”: “col4”,
“dataPath”: “datesAndTimesAvailable”,
“label”: “Availability”,
“width”: 100,
“visible”: true ,
“type”: “string”,
}];
})

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

my site URL is www.reidreadycoaching.com Let me know if you need anything else.