Image above is an example of what I want to achieve.
User can input a unique VIN number in the search bar and it will search a database or multiple databases for a match.
Display a message after finishing the search.
Can this be done in Wix?
Image above is an example of what I want to achieve.
User can input a unique VIN number in the search bar and it will search a database or multiple databases for a match.
Display a message after finishing the search.
Can this be done in Wix?
Of course this can be done!
This for read the Wix-Data-Documentation in the Wix-Velo-Api
Thanks for the reply, was wondering you could show me an example code. Not really privy in matching data with a query
You have a DATABASE ? What is the ID of your DATABASE ?
let dbID = “putInHere_DB_ID/COLLECTION_ID”;
You are searching inside a specific FIELD, for a specific VALUE ?
let dbFIELD = “putInHere_DB_FIELD_ID”;
The VALUE you are searching for …
let VALUE = “this will be the value, you are searching for in DB, in specific FIELD”
let VALUE = “XYZ”;
So lets create some code and generate our first SEARCH-ENGINE!
import wixData from 'wix-data';
$w.onReady( function() {
let dbID = "DATABASE_ID_HERE";
let dbFIELD = "DBFIELD_ID_HERE";
let VALUE = "mySearchValueHere";
wixData.query(dbID)
.eq(dbFIELD, VALUE)
.find()
.then((res)=>{let ITEMS = res.items; console.log("ITEMS: ", ITEMS);})
.catch((err)=>{console.log(err)});
})
Your first Data-Query (Search-Function)!
Thank you Ninja, I will try it out!
I have put it in the code in my page and it looks like this now
import wixData from “wix-data”
$w . onReady ( function () {
let dbID = “Recall” ;
let dbFIELD = “title” ;
let VALUE = $w ( ‘#input1’ );
wixData . query ( dbID )
. eq ( dbFIELD , VALUE )
. find ()
. then (( res )=>{ **let** ITEMS = res . items ; console . log ( "ITEMS: " , ITEMS );})
. **catch** (( err )=>{ console . log ( err )});
})
It doesn’t do anything at all after input. I want to use the search button to execute the query and return the results in a message. Struggling with this now
Hello,
there is no SEARCH-BUTTON coded in your shown code.
importwixDatafrom "wix-data"
$w.onReady(function(){
let dbID= "Recall";
let dbFIELD= "title";
$w("#mySearchButtonIdhere").onChange((event)=>{console.log("changed");
let VALUE = $w('#input1');
wixData.query(dbID)
.eq(dbFIELD,VALUE).find()
.then((res)=>{
let ITEMS = res.items;
console.log("ITEMS: ",ITEMS);
})
.catch((err)=>{console.log(err)});
});
});
Then you open the CONSOLE and take a look onto the given RESULTS.
The console you will find by clicking “F-12” if you use GOOGLE-CHROME.
Or you do it in the integrated CONOSLE of the wix-editor.