> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Sample Flows ## Article: Sample Flows ## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/cms/sample-flows.md ## Article Content: # Wix Data APIs: Sample Use Cases & Flows This article presents sample use cases and corresponding flows that demonstrate how to use the Wix Data APIs together. These can be a helpful starting point as you plan your implementation. ## Set up a job board You can use multiple Data APIs to create a fully configured job board system. This flow creates collections with proper schemas, adds indexes for query optimization, and populates the collections with initial data. To set up a job board: 1. Call [Create Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection.md) to create a `companies` collection. Include the following properties in your request: In the `fields` array, include fields with these recommended values for `type`: - `name`, `slug`, and `location`: `TEXT` - `description`: `RICH_TEXT` - `logo`: `IMAGE` - `website`: `URL`

Set the values in `permissions` as follows: - `read`: `ANYONE` so visitors can view the listings. - `insert`, `update`, and `remove`: `ADMIN` so only site owners can manage content.

1. Call [Create Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection.md) to create a `jobs` collection. Include the following properties in your request: In the `fields` array, include fields with these recommended values for `type`: - `title`, `slug`, `location`, `employmentType`, and `status`: `TEXT` - `description`: `RICH_TEXT` - `salaryMin` and `salaryMax`: `NUMBER` - `postedDate` and `deadline`: `DATETIME`

Also include the following `fields` to add a cross reference for the `companies` collection created earlier. - `company`: with `type` set to `MULTI_REFERENCE` and `typeMetadata.multireference.referencedCollectionId` set to `companies`.

Set `permissions` to control the collection's access as follows: - `read`: `ANYONE` so visitors can view the companies' details. - `insert`, `update`, and `remove`: `ADMIN` so only site owners can manage content.

1. Call [Create Index](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/indexes/create-index.md) to create an index on the `jobs` collection for the `status` and `postedDate` fields to accelerate queries for open jobs sorted by date. 1. Call [Create Index](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/indexes/create-index.md) to create an index on `location` to accelerate location-based job searches. 1. Call [Bulk Insert Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/bulk-insert-data-items.md) to populate the `companies` collection with company profiles. 1. Call [Bulk Insert Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/bulk-insert-data-items.md) to populate the `jobs` collection with job listings, referencing the company IDs from the previous step. ## Add fields to an existing collection and migrate data You can extend an existing collection's schema and migrate data to populate the new fields. This is useful when evolving your data model over time. To add fields and migrate data: 1. Call [Get Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/get-data-collection.md) to retrieve the current `jobs` collection schema and `revision` number. 2. Call [Create Data Collection Field](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection-field.md) for the `jobs` collection to add a new `remote` field with `type` set to `BOOLEAN`. 3. Call [Query Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-data-items.md) to retrieve all existing job listings. 4. Call [Bulk Update Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/bulk-update-data-items.md) to update each job with a `remote` value based on the `location` field. For example, set to `true` if location contains `"Remote"`. 5. Call [Create Index](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/indexes/create-index.md) to add an index on the new `remote` field if you plan to filter by it frequently. ## Back up and restore collection data You can create a backup of your collections before making significant changes, then restore the data if needed. This is useful for protecting against accidental data loss during migrations or bulk updates. To back up and restore data: 1. Call [Create Backup](https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/backups/create-backup.md) to create a full backup of your site's collections. The response includes a `backupId`. 1. Make your changes to the collections using the [Data Items API](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction.md) to insert, update, or remove items. 1. If you need to revert the changes, call [Restore Backup](https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/backups/restore-backup.md) with the `backupId` from step 1. 1. Alternatively, call [Restore Partial Backup](https://dev.wix.com/docs/api-reference/business-solutions/cms/operations/backups/restore-partial-backup.md) to restore only specific collections by specifying the collection IDs. ## Query and aggregate job listings You can combine querying and aggregation to build rich job search features. This flow retrieves jobs with their company details and calculates hiring statistics. To query and aggregate job data: 1. Call [Query Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-data-items.md) with `dataCollectionId` set to `jobs`: - In `query.filter`, set `status` to `"open"` and `location` to the target city. - In `query.sort`, sort by `postedDate` in descending order to show newest jobs first. - Set `includeReferencedItems` to `["company"]` to include full company details in the response. 2. Call [Aggregate Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/aggregate-data-items.md) to calculate hiring statistics: - Set `groupingFields` to `["location"]`. - Add operations for `itemCount` (total jobs per location) and `average` on `salaryMax` (average maximum salary). 3. Call [Count Data Items](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/count-data-items.md) with a filter for `status` equals `"open"` to display the total number of open positions.