Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.datesIdCollection = this.afs.collection('dates');
- this.afs.collection('dates').valueChanges().subscribe(dateIdAmounts =>{
- this.dateIdAmounts = dateIdAmounts as DateAmountId[];
- });
- updateOrAddToDates(){
- for(let dateAmount of this.dateIdAmounts){
- for (let selectedDate of this.selectedDates) {
- if(selectedDate.getTime()=== dateAmount.date.getTime()){
- this.datesCollection.doc(dateAmount.id).update(new DateAmount(selectedDate, this.amount));
- }else{
- this.pushToDates(new DateAmount(selectedDate, this.amount));
- break;
- }
- }
- }
- }
- pushToDates(datAmount){
- const datum = new Date();
- this.datesCollection.add({
- amount: datAmount.amount,
- date: datAmount.date
- }).then(
- (docRef) =>{
- this.datesCollection.doc(docRef.id).update({
- id: docRef.id
- })
- }
- );
- }
Add Comment
Please, Sign In to add comment