Manage a data collection through a site.
In this example, we use the Wix Data API to perform CRUD (Create, Read, Update, Delete) operations through simple button clicks. Site visitors can enter a language and greeting in the text input fields and select a greeting from a repeater, allowing them to add, edit, and delete items from the Greetings collection.
This example demonstrates how to create, read, update, and delete data from collections using frontend interactions and backend functions..
To help protect your site's data from misuse, it's important to understand how collection permissions are managed in Wix. You can read more about collection permissions here.
For this example, the collection permissions have been set to Private to test in Preview mode. If you plan to use this example on a live site, make sure to review and update the collection's permissions accordingly.
Additionally, consider using Live Site Item Visibility to control which data is visible to visitors on your site.
We added the following to our site:
The code in this file initializes the page’s elements, listens for button clicks, and performs CRUD operations called from the backend based on the button that is clicked.
In this file, we:
createGreeting()
function with the provided input values when the Create button is clicked.updateGreeting()
with the updated user input values when the Update button is clicked.deleteGreeting()
when the Delete button is clicked.In this file we define the functions that are called from the frontend, and work directly with the collection to create, read, update and delete data. These functions include:
readGreetings()
- returns all the greetings in the collection to the frontend.createGreeting()
- inserts a new item into the collection.updateGreeting()
- update's the selected item in the collection.deleteGreeting()
- removes an item from the collection.Join the Wix Studio community on Discord, where experienced developers and fellow creators come together to share tips, troubleshoot issues, and collaborate.
Building a coded solution on your own can be challenging. Let an experienced Wix developer build it for you, so you can keep working on your site or business. Visit the Wix Marketplace to find a trusted developer.