-
Notifications
You must be signed in to change notification settings - Fork 115
Description
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