An ordinary simple query…
import wixData from 'wix-data';
$w.onReady(function () {
xxx();
});
function xxx() {
wixData.query("myCollectionIDhere")
.find()
.then((results) => {
if(results.items.length > 0) {
console.log("My-Found-Results: ", results.items);
} else { }
})
.catch((err)=> {console.log(err);});
}
Adding filter-options to your ordinary-query…(example)…
import wixData from 'wix-data';
$w.onReady(function () {
xxx();
});
function xxx() {
wixData.query("myCollectionIDhere")
.eq("dbFieldID", "value")
.contains("dbFieldID", "value")
.hasSome("dbFieldID", ["value1", "value2", "value3"...])
.hasAll("dbFieldID", ["value1", "value2", "value3",...])
.find()
.then((results) => {
if(results.items.length > 0) {
console.log("My-Found-Results: ", results.items);
} else { }
})
.catch((err)=> {console.log(err);});
}
Here you get the results…
...
...
.find()
.then((results) => {
if(results.items.length > 0) {
console.log("My-Found-Results: ", results.items);
} else { }
...
...
...
But what exactly you want to UPDATE ? Of course the found and modified data, right?
...
.find()
.then((results) => {
if(results.items.length > 0) {
console.log("My-Found-Results: ", results.items);
let items = results.items
//changing for example TITLE ...
items[0].title = "xxxxxxxx";
} else { }
...
Updating …
let options = {
"suppressAuth": true,
"suppressHooks": true
};
wixData.update("myCollection", items[0], options)
.then((results) => {console.log(results);})
.catch((err) => {console.log(err);
});
…or BULK-UPDATE…
wixData.bulkUpdate("myCollection", items, options)
.then((results) => {console.log(results);})
.catch((err) => {console.log(err);
});
Working on a DYNAMIC-DATASET…
$w.onReady(function() {
$w('#dynamicDataset').onReady(()=>{
let curItem = $w('#dynamicDataset').getCurrentItem();
console.log("My-Current-Item-Data: ", curItem);
console.log(curItem.title);
console.log(curItem._id);
console.log(curItem._owner);
});
});
Take a look onto all this and try to generate your code out of the shown example-parts.