This is my template where i am trying to put a value automaticly inside of a text box instead of user. I want the value to be the last ID of my documents + 1.
<v-text-field style="width:170px"
value=""
label = "ID_Naloge"
v-model="ID"
prepend-icon=""
type = "number"
:rules="rules.name"
placeholder=""
disabled
required
>
</v-text-field>
This is my import:
var b = this.countLastItem();
console.log(b);
This is what i want to return:
ID: parseInt(Number(this.b)) + 1
This is my method that is returnih Nan everytime instead of number eg. 44 (because there are 44 documents + 1):
countLastItem(){
db.collection("Kontrolne naloge").get().then(function(querySnapshot) {
console.log(querySnapshot.size);
return Number(querySnapshot.size);
});
the console log returns 43
this is how my submit code looks like:
submit() {
this.snackbar = true
const project = {
ID_Naloge: Number(this.ID),
Kriterij_FK: Number(this.Kriterij),
Letnik_FK: Number(this.Letnik),
Naslov: this.Naslov,
Poglavje_FK: Number(this.Poglavje),
Predmet_FK: Number(this.Predmet),
Rešitev_FK: Number(this.Rešitev),
Stopnja_Težavnosti_FK: Number(this.Stopnja),
To?ke: Number(this.To?ke),
}
db.collection('Kontrolne naloge').add(project).then(() => {
console.log(this.ID)
})
this.resetForm();
},