Links

Creating Collections

A collection is a group of documents. For example, you could have a 'users' collection that contains a list of documents, each representing a single user.
User collection document model

Getting Started: Things to Know First

  1. 1.
  2. 2.
    Ensure you've gone through and completed every step in the Firebase Setup for your project.

Creating a collection

Here are the steps to create a collection:
  1. 1.
    Click on the Firestore from the Navigation Menu (left side of your screen).
  2. 2.
    Click on the (+) Plus sign button.
  3. 3.
    A popup will appear, Enter the collection name and click Create Button.
  4. 4.
    Next, define the collection schema (create Fields) and add some data to the collection.
A collection will only appear on Firebase Console if it contains at least one document.

Define schema (creating Fields)

A document represents a single item or entity, such as a user, post, animal, etc. To add data inside the document, you must define the document schema by creating Fields. Creating Fields helps you know what kind of data a document can contain.
Although you can add more fields later on, it's always a good idea to add fields from the start.
Field names can not be changed, so ensure that you have used the correct Field names.
To define the schema (create fields) for the document:
  1. 1.
    Select your collection from the list on the left side.
  2. 2.
    If you haven't added any fields yet:
    1. 1.
      You can choose from the template collections that have common fields needed in most applications. This will auto-add all the fields.
    2. 2.
      Click on Start from scratch to define your own schema.
    3. 3.
      Or, use AI Gen Schema.
  3. 3.
    To add a new field, start typing its name (e.g., title, description, date, etc.) and choose the suitable Data Type.
  4. 4.
    While choosing the Data Type, you can set if it will be a list or not using Is List? toggle.
    1. 1.
      You can keep it disabled for storing only a single value. For example, fields such as title, description, price, etc., can have only one value. You can't have multiple titles for a single post.
    2. 2.
      You can enable it to store multiple values of the same data type. For example, to store the list of accessory names for the field accessories.
  5. 5.
    Click on the Done icon.
You can also use Tab and Enter keys to navigate quickly while creating fields.

AI Gen Schema

With 'AI Gen Schema,' you can automatically generate a schema for your Firebase collection from a simple prompt.
To get the desired result, you can try optimizing your prompt. i.e., make it more descriptive.
Examples:
  • Generate a collection for books, their reviews, and their purchase history.
  • Create a database schema for music albums, their ratings, and sales records.
  • Generate a collection for video games, their user reviews, and purchase history.
  • Create a collection for art exhibits, visitor reviews, and ticket bookings.
  • Generate a collection for online courses, student feedback, and enrollment records.

Data Types within FlutterFlow

The following data types are available within FlutterFlow:
  • String: To store plain text such as title, description, etc.
  • Integer: To store numbers such as 100, 4302, 50000, etc.
  • Double: To store a decimal number such as 12.43, 3233.50, 65.5666, etc.
  • Photo Path: To store the URL of the uploaded image.
  • Video Path: To store the URL of the uploaded video.
  • Audio Path: To store the URL of the uploaded audio.
  • Boolean: To store either a true or false value.
  • Timestamp: To store date and time value.
  • Lat Lng: To store the latitude and longitude of a particular place. Storing the Lat Lng value helps you locate a place in Google Maps.
  • Color: To store the color value.
  • Document Reference: To store a reference of a document. Storing a reference helps you fetch the document data.
  • Data Type: To store custom data types.

Last Updated Date: September 6, 2023