Refactor to reflect db structure changes
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { doc, updateDoc, arrayUnion } from 'firebase/firestore'
|
import { collection, addDoc } from 'firebase/firestore'
|
||||||
// We use vee-validate@3 for form validation.
|
// We use vee-validate@3 for form validation.
|
||||||
// https://vee-validate.logaretm.com/v3/guide/basics.html
|
// https://vee-validate.logaretm.com/v3/guide/basics.html
|
||||||
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate'
|
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate'
|
||||||
@@ -86,11 +86,9 @@ export default {
|
|||||||
status: 'neu'
|
status: 'neu'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atomically add the new question to the "geschlossen" (fragen/{kursID}/geschlossen) array field.
|
// Add a new document with a generated id.
|
||||||
const questionsRef = doc(this.$db, 'fragen', this.$store.state.selectedCourse)
|
addDoc(collection(this.$db, `kurse/${this.$store.state.selectedCourse}/fragenGeschlossen`), q)
|
||||||
updateDoc(questionsRef, {
|
.then((docRef) => {
|
||||||
geschlossen: arrayUnion(q) // Ref: https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
|
|
||||||
}).then((empty) => {
|
|
||||||
// Successfully added new question to database
|
// Successfully added new question to database
|
||||||
this.$toast({ content: 'Deine Frage wurde eingereicht!', color: 'success' })
|
this.$toast({ content: 'Deine Frage wurde eingereicht!', color: 'success' })
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { doc, updateDoc, arrayUnion } from 'firebase/firestore'
|
import { collection, addDoc } from 'firebase/firestore'
|
||||||
// We use vee-validate@3 for form validation.
|
// We use vee-validate@3 for form validation.
|
||||||
// https://vee-validate.logaretm.com/v3/guide/basics.html
|
// https://vee-validate.logaretm.com/v3/guide/basics.html
|
||||||
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate'
|
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate'
|
||||||
@@ -85,11 +85,9 @@ export default {
|
|||||||
schwierigkeit: []
|
schwierigkeit: []
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atomically add the new question to the "offen" (fragen/{kursID}/offen) array field.
|
// Add a new document with a generated id.
|
||||||
const questionsRef = doc(this.$db, 'fragen', this.$store.state.selectedCourse)
|
addDoc(collection(this.$db, `kurse/${this.$store.state.selectedCourse}/fragenOffen`), q)
|
||||||
updateDoc(questionsRef, {
|
.then((docRef) => {
|
||||||
offen: arrayUnion(q) // Ref: https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
|
|
||||||
}).then((empty) => {
|
|
||||||
// Successfully added new question to database
|
// Successfully added new question to database
|
||||||
this.$toast({ content: 'Deine Frage wurde eingereicht!', color: 'success' })
|
this.$toast({ content: 'Deine Frage wurde eingereicht!', color: 'success' })
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user