DocumentArgs

data class DocumentArgs(val collection: Output<String>? = null, val database: Output<String>? = null, val documentId: Output<String>? = null, val fields: Output<String>? = null, val project: Output<String>? = null) : ConvertibleToJava<DocumentArgs>

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 a Firestore database. If you haven't already created it, you may create a gcp.firestore.Database resource with type set to "FIRESTORE_NATIVE" and location_id set to your chosen location. If you wish to use App Engine, you may instead create a gcp.appengine.Application resource with database_type set to "CLOUD_FIRESTORE". 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-id")
.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-id")
.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}}

Constructors

Link copied to clipboard
constructor(collection: Output<String>? = null, database: Output<String>? = null, documentId: Output<String>? = null, fields: Output<String>? = null, project: Output<String>? = null)

Properties

Link copied to clipboard
val collection: Output<String>? = null

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

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

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

Link copied to clipboard
val documentId: Output<String>? = null

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

Link copied to clipboard
val fields: Output<String>? = null

The document's fields formated as a json string.

Link copied to clipboard
val project: Output<String>? = null

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

Functions

Link copied to clipboard
open override fun toJava(): DocumentArgs