Document

In Cloud 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. To get more information about Document, see:

Warning: This resource creates a Firestore Document on a project that already has Firestore enabled. If you haven't already enabled it, you can create a gcp.appengine.Application resource with database_type set to "CLOUD_FIRESTORE" to do so. Your Firestore location will be the same as the App Engine location specified.

Example Usage

Firestore Document Basic

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Document;
import com.pulumi.gcp.firestore.DocumentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var mydoc = new Document("mydoc", DocumentArgs.builder()
.collection("somenewcollection")
.documentId("my-doc-%{random_suffix}")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}")
.project("my-project-name")
.build());
}
}

Firestore Document Nested Document

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Document;
import com.pulumi.gcp.firestore.DocumentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var mydoc = new Document("mydoc", DocumentArgs.builder()
.collection("somenewcollection")
.documentId("my-doc-%{random_suffix}")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"akey\":{\"stringValue\":\"avalue\"}}}}}")
.project("my-project-name")
.build());
var subDocument = new Document("subDocument", DocumentArgs.builder()
.collection(mydoc.path().applyValue(path -> String.format("%s/subdocs", path)))
.documentId("bitcoinkey")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"ayo\":{\"stringValue\":\"val2\"}}}}}")
.project("my-project-name")
.build());
var subSubDocument = new Document("subSubDocument", DocumentArgs.builder()
.collection(subDocument.path().applyValue(path -> String.format("%s/subsubdocs", path)))
.documentId("asecret")
.fields("{\"something\":{\"mapValue\":{\"fields\":{\"secret\":{\"stringValue\":\"hithere\"}}}}}")
.project("my-project-name")
.build());
}
}

Import

Document can be imported using any of these accepted formats

$ pulumi import gcp:firestore/document:Document default {{name}}

Properties

Link copied to clipboard
val collection: Output<String>

The collection ID, relative to database. For example: chatrooms or chatrooms/my-document/private-messages.

Link copied to clipboard
val createTime: Output<String>

Creation timestamp in RFC3339 format.

Link copied to clipboard
val database: Output<String>?

The Firestore database id. Defaults to "(default)".

Link copied to clipboard
val documentId: Output<String>

The client-assigned document ID to use for this document during creation.

Link copied to clipboard
val fields: Output<String>

The document's fields formated as a json string.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

A server defined name for this index. Format: projects/{{project_id}}/databases/{{database_id}}/documents/{{path}}/{{document_id}}

Link copied to clipboard
val path: Output<String>

A relative path to the collection this document exists within

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val updateTime: Output<String>

Last update timestamp in RFC3339 format.

Link copied to clipboard
val urn: Output<String>