Hello Everybody,
I have got two databases among which are “Bookingdetails”, and “PastCustomers”. Booking details database is where all the recent booking are stored, and I would like to move that particular row of data into another database " Pastcustomers" upon button click. I have made a search bar to retrieve the guest booking information (which is working perfectly), but quite couldn’t figure out how to select that row or move that data into another database. Any help will be highly appreciated.
Thank you in advance!
Cheers
Once I click retrieve button, I am getting the results as expected, and the move button also lies inside the repeater. I should be able to insert data into another database with that “move button”…
//importing all the local files
import {local} from ‘wix-storage’;
import { pdf } from ‘backend/pdf.jsw’;
import wixData from ‘wix-data’;
//Start of Customers booking management Center
//to have search results
$w.onReady( function () {
$w(“#dataset1”).refresh();
var sameWord = local.getItem(“searchWord”);
$w(“#searchBar”).value = sameWord;
$w(‘#dataset1’).onReady( function () {
search();
});
});
function search() {
wixData.query(‘Bookingdetails’)
.eq(‘title’, $w(“#searchBar”).value)
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
$w(‘#repeater11’).data = res.items;
$w(‘#repeater12’).data = res.items;
$w(“#image46”).hide();
});
}
export function searchButton_click(event) {
search();
$w(“#image46”).show();
$w(‘#columnStrip21’).expand();
$w(‘#repeater1’).expand();
$w(‘#repeater11’).expand();
$w(‘#repeater12’).expand();
}
**USING THIS UPTO HERE TO FIND THE RESPECTIVE INFORMATION OF GUEST AND IS WORKING PERFECTLY
**NOW I WOULD LIKE TO MOVE THAT PARTICULAR DISPLAYED RESULTS (LIES WITHIN THE SAME ROW OF “BOOKINGDATABASE”, INTO THE NEW DATABASE CALLED “PASTCUSTOMERS” USING BUTTON
export function movebutton_click(event) {
wixData.query('Bookingdetails')
.eq('title', $w("#searchBar").value)
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
$w(‘#repeater11’).data = res.items;
$w(‘#repeater12’).data = res.items;
$w(“#image46”).hide();
})
search();
let toinsert = search.items;
//Add your code for this event here:
wixData.insert("pastcustomers", toinsert) //inserts the item
.then( (results) => {
let items = results;
console.log(“done adding item”)
} )
. catch ( (err) => {
let errorMsg = err;
} );
}