// Backend file: backend/createBusinessesCollection.js
// This function creates a "Businesses" CMS collection with all specified fields,
// including a structured "Location" object for latitude and longitude.
import { collections } from '@wix/data';
export async function createBusinessesCollection() {
try {
const result = await collections.createDataCollection({
collectionId: "Businesses",
displayField: "Business Name",
displayName: "Businesses",
fields: [
{ key: "Business Name", displayName: "Business Name", type: "TEXT", required: true },
{ key: "Slug", displayName: "Slug", type: "TEXT" },
{ key: "Business Logo", displayName: "Business Logo", type: "IMAGE" },
{ key: "Cover Image", displayName: "Cover Image", type: "IMAGE" },
{ key: "Business Photos", displayName: "Business Photos", type: "MEDIA_GALLERY" },
{ key: "Description", displayName: "Description", type: "TEXT" },
{ key: "Category", displayName: "Category", type: "TEXT" },
{ key: "Subcategory", displayName: "Subcategory", type: "TEXT" },
{ key: "Phone", displayName: "Phone", type: "TEXT" },
{ key: "Email", displayName: "Email", type: "TEXT" },
{ key: "Website", displayName: "Website", type: "TEXT" },
{ key: "Street Address", displayName: "Street Address", type: "TEXT" },
{ key: "City", displayName: "City", type: "TEXT" },
{ key: "State", displayName: "State", type: "TEXT" },
{ key: "ZIP Code", displayName: "ZIP Code", type: "TEXT" },
{ key: "Country", displayName: "Country", type: "TEXT" },
// Structured location object
{ key: "Location", displayName: "Location", type: "OBJECT" },
{ key: "Service Area", displayName: "Service Area", type: "TEXT" },
{ key: "Hours", displayName: "Hours", type: "TEXT" },
{ key: "Rating", displayName: "Rating", type: "NUMBER" },
{ key: "Review Count", displayName: "Review Count", type: "NUMBER" },
{ key: "Years in Business", displayName: "Years in Business", type: "NUMBER" },
{ key: "Verified Business", displayName: "Verified Business", type: "BOOLEAN" },
{ key: "Featured Business", displayName: "Featured Business", type: "BOOLEAN" },
{ key: "Active Listing", displayName: "Active Listing", type: "BOOLEAN" },
{ key: "Business Owner", displayName: "Business Owner", type: "TEXT" },
{ key: "Date Added", displayName: "Date Added", type: "DATETIME" },
{ key: "Last Updated", displayName: "Last Updated", type: "DATETIME" }
],
permissions: {
insert: "ADMIN",
read: "ANYONE",
remove: "ADMIN",
update: "ADMIN"
}
});
return result;
} catch (error) {
console.error(error);
throw error;
}
}
top of page
bottom of page