Skip to content

firestore.createDocuments isn't passing back filled information: #175

@itskelechi

Description

@itskelechi

const firestore = getFirestoreDB();
const name = "Quiz 1";
const quizId = 12345;
try {
const docData = {
"quizId": ${quizId},
"name": ${name},
"metadata": {}
};

firestore.createDocument(`quizConfigs/${quizId}`, docData);

return quizId;

} catch (error) {
Logger.log("Error creating quiz config: " + error.stack || error);
throw error;
}

function getFirestoreDB() {
const props = PropertiesService.getScriptProperties();

const projectId = (props.getProperty("project_id"));
const privateKey = (props.getProperty("private_key")).replace(/\n/g, "\n");
const clientEmail = (props.getProperty("client_email"));

if (!projectId || !clientEmail || !privateKey) {
throw new Error(
"Missing Firestore Script Properties. Need PROJECT_ID, CLIENT_EMAIL, PRIVATE_KEY."
);
}

return FirestoreApp.getFirestore(clientEmail, privateKey, projectId);
}


## Expected Behavior
- Document is created called quizConfigs/12345
- Fields in document for:  quizId, name,metadata


## Actual Results
Document is created but there are no corresponding fields

##### Library Version: 33

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions