Got a database collection with content you'd like to display on your site? Want to get content from your site visitors and store it? Here's what you can do:
Dataset: the no-code alternative
You might just use a dataset, a connector between your page elements and the content in your database collections. Datasets allow you to display, filter, sort, and limit database content on your site, and to save content from your page elements to your database collection, all without any code. (Note: You can expand a dataset's basic functionality with dataset-specific code.)
But sometimes you might need additional functionality that isn't available with datasets. Or you might find it easier to organize your data operations by handling them only with code instead of via the UI.
You can use the Wix Data APIs for this purpose. The Data APIs provide you with additional functionality and customization options for managing and manipulating your site content. Here's an overview of what you can do with Wix Data:
Save content to a collection
insert(): Add an item to a collection
save(): Add or update an item in a collection
update(): Update an item in a collection
bulkInsert(): Add multiple items to a collection
bulkSave(): Add or update multiple items in a collection
bulkUpdate(): Update multiple items in a collection
Delete content from a collection
remove(): Remove an item from a collection
bulkRemove(): Remove multiple items from a collection
truncate(): Remove all items from a collection
Get content from a collection
...and then display it on your site
get(): Retrieve a single item from a collection
query(): Start a process that will retrieve 1 or more items from a collection. The process is completed when you run the find() function.
Filter and Sort your retrieved data
Code only
WixDataQuery functions: Apply these to a query to filter or sort your retrieved data
Dataset + code
filter(): Create a filter to use with datasets
WixDataFilter functions: Apply these to filter the results returned by your dataset
Limit your retrieved data
Paginate your query results
Use the WixDataQueryResult next() and prev() functions to paginate through the results of a query.
You can also paginate the results of a referenced query.
Work with collection reference fields
insertReference(): Insert a reference to an item/items
isReferenced(): Check whether a reference to an item exists
queryReferenced(): Get referenced items
removeReference(): Remove a reference
replaceReferences(): Replace references with other references
Aggregate: Perform calculations on collection data
aggregate(): Build an aggregation
sum(): Calculate the sum of all values of a collection field
avg(): Calculate the average value of a collection field
count(): Calculate the item count of each aggregation group
max(): Get the maximum value from each aggregation group
min(): Get the minimum value from each aggregation group
Hooks: Perform actions before or after specific data operations
You can run any code you want via a hook immediately prior to or following specific data operations, such as insert(), remove(), update() and query().