Skip to content

Cloud Firestore Representation

Gino Miceli edited this page Nov 13, 2019 · 13 revisions

This page describes how Ground data is structured in Cloud Firestore. For definitions of terminology used throughout this document, please refer to Key Concepts.

Database hierarchy

Cloud Firestore databases are composed of collections (πŸ“) and documents (πŸ“„). Collections may contain one or more documents, which themselves may can contain other collections, and so on, ad infinitum. For a full explanation see Cloud Firestore Data Model.

Ground data is organized in Cloud Firestore as follows:

πŸ“‚projects/
  πŸ“„${projectId}
    πŸ“‚features/
      πŸ“„${featureId}
    πŸ“‚observations/
      πŸ“„${observationId}
πŸ“‚users/
  πŸ“„${userId}

Where ${projectId}, ${featureId}, ${observationId}, etc., indicate zero or more documents keyed by auto-generated UUIDs.

User-controlled i18n

User-defined multilingual strings like title and description are stored as associative arrays keyed by ISO-639 language code.

Document structure

Projects

Path: /projects/${projectId}

Project settings, form definitions, and ACLs defined by project managers are stored in documents with the following structure:

{
  title: { 'en': 'Project title' },
  description: { 'en': 'Project description' },
  owner: 'user1234',
  layers: {
    layer001: {
      name: { 'en': 'Layer name' },
      zIndex: 1,
      forms: {
        formId: {
          elements: [
            {
              id: 'element001',
              label: { 'en': 'Question 1' },
              required: true,
              type: 'text_field'
            },
            {
              id: 'element002',
              label: { 'en': 'Question 2' },
              required: false,
              type: 'multiple_choice',
              cardinality: 'select_one',
              options: [
                {
                  code: 'A',
                  label: { 'en': 'Option A' }
                },
                // More options...
              ]
            },
            // More elements...
          ]
        }
      }
    }
  },
  acl: {
    user001: 'viewer',
    user002: 'contributor',
    user003: 'manager',
    // More users...
  }
}

Features

{
  location: {
    latitude: -74.0060,
    longitude: 40.7128
  },
  layerId: 'layer1234'
}

Observations

TODO: Merge in description from https://github.com/google/ground-platform/issues/9.

Clone this wiki locally