191 |
457 |
457 |
456 |
456 |
456 |
456 |
123 |
798 |
qwe |
123 |
125221 |
1252122 |
yuyt7456 |
cvbcv |
cvbcv |
cvbcv |
45454 |
123 |
123 |
111 |
222 |
555 |
555 |
1234 |
331122 |
amy |
dfhdgdf |
1234 |
1234 |
532134 |
331122 |
12345 |
1234 |
123 |
- - - -
- - - - -
How to --> Key-Check
Generate some new keys with [Set new Key], which will be saved in database. The table shows all keys which are stored in database.
​
Type in a KEY and do a validation-query with [VALIDATE].
​
Is your key already in the database ???????????????????
import wixData from 'wix-data';
$w.onReady(function () { });
export function button1_click(event) {set_NewValue()}
function start_VALIDATION () {
wixData.query("Validation")
.find()
.then( (results) => {
if(results.items.length > 0) {
let itemsAmount = results.length
let firstItem = results.items[0];
let foundKey = ""
for (var i = 0; i < itemsAmount; i++) {
console.log(results.items[i].column1)
if ($w('#input1').value == results.items[i].column1){foundKey = results.items[i].column1, console.log("KEY-FOUND")}
else {console.log("NO-KEY-FOUND")}
}
if (foundKey>0) {$w('#TXToutput').text = "KEY-FOUND", $w('#TXTkey').text = foundKey}
else {$w('#TXToutput').text = "NO-KEY-FOUND", $w('#TXTkey').text = ""}
}
else { }
})
.catch( (err) => {
let errorMsg = err;
} );
}
export function button2_click(event) {start_VALIDATION()}
function set_NewValue() { console.log("SET")
let myValue = $w('#input1').value
let toInsert = {"column1": myValue};
wixData.insert("Validation", toInsert)
.then( (results) => {
let item = results;
$w('#dataset1').refresh()
} )
.catch( (err) => {
let errorMsg = err;
} );
}