Escriu per cercar…

Firestore

Cloud Firestore is a NoSQL, document-oriented database.

Aquesta pàgina encara no s'ha traduït — es mostra en l'idioma original:English

Introduction

Cloud Firestore is a flexible, scalable NoSQL cloud database, built on Google Cloud infrastructure, to store and sync data for client- and server-side development.

Go to the Firebase console and create a project.

Data model

The Cloud Firestore data model supports whatever data structure works best for our app: unlike a SQL database, there are no tables or rows.

Instead, you store data in documents, which are organized into collections.

Each document contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.

All documents must be stored in collections. Documents can contain subcollections and nested objects, both of which can include primitive fields like strings or complex objects like lists.

Collections and documents are created implicitly in Cloud Firestore. Simply assign data to a document within a collection. If either the collection or document does not exist, Cloud Firestore creates it.

Documents

In Firestore, the unit of storage is the document. A document is a lightweight record that contains fields, which map to values. Each document is identified by a name.

A document representing a user alovelace might look like this:

📄 alovelace
   first : "Ada"
   last : "Lovelace"
   born : 1815

Firestore supports a variety of data types for values: boolean, number, string, geo point, binary blob, and timestamp. You can also use arrays or nested objects, called maps, to structure data within a document.

Complex, nested objects in a document are called maps.

For example, you could structure the user’s name from the example above with a map, like this:

📄 alovelace
   name :
      first : "Ada"
      last : "Lovelace"
   born : 1815

You may notice that documents look a lot like JSON:

json
{
  "name": {
    "first": "Ada",
    "last": "Lovelace"
  },
  "born": 1815
}

In fact, they basically are. There are some differences (for example, documents support extra data types and are limited to the document size limit), but in general, you can treat documents as lightweight JSON records.

Collections

Documents live in collections, which are simply containers for documents.

For example, you could have a users collection to contain your various users, each represented by a document:

txt
📁 users
   📄 alovelace
      first : "Ada"
      last : "Lovelace"
      born : 1815
   📄 aturing
      first : "Alan"
      last : "Turing"
      born : 1912

Estàs llegint una vista prèvia.

Inicia sessió per llegir l'article complet. Qualsevol compte obre 4 articles gratuïts al mes; l'alumnat i el professorat llegeixen les pàgines del seu curs sense límit.

Inicia sessió