I want every data sent last to be sorted as the last mongo document in my firebase collection. In any case, the last sent data will be stored as the last document in the collection. I used sorting by dates and current time but it is not effective for all dates. (for example date 2.6 puts first instead of 19.6)
This is my function:
Reservations(){
this.user = store.currentUser
this.empty_form=false;
if(this.current_museum!=''&&this.date!=''&&this.ticket_number!=''&&this.user!='')
{
//Date I used for sorting
const current = new Date();
const date = current.getFullYear()+'-'+(current.getMonth()+1)+'-'+current.getDate();
const time = current.getHours() + ":" + current.getMinutes() + ":" + current.getSeconds();
const dateTime = date +' '+ time;
let counter = counter + 1;
router.replace({path:'/ticket_reserved', replace: true})
try {
db.collection("reservations")
.doc(dateTime)
.set({
current_museum: this.current_museum,
date: this.date,
ticket_number: this.ticket_number,
user: this.user
});
}
catch(error) {
}
}else{
this.empty_form=true;
}},