Good Morning,
I tried adding a new created object from this class:
export class Sponsor implements ISponsor {
title: string;
description?: s
It's really strange behavior from firebase. And that how I fixed it - by creating new Interface and adding convertation method to my class:
export class Happening {
constructor(
public date: EventDate,
public participants: Array,
public title: string,
public text: string,
public uid?: string,
public id?: string
){}
public toDto = (): HappeningDto => {
return {
date: {
year: this.date.year,
month: this.date.month,
day: this.date.day
},
participants: this.participants ? this.participants : [],
title: this.title,
text: this.text ? this.text : '',
uid: this.uid,
id: this.id ? this.id : null
}
}
}
export interface HappeningDto {
date: {
year: number,
month: number,
day: number
},
participants: Array,
title: string,
text: string,
uid?: string,
id?: string
}
Now, I can do
add(event: Happening){
event.uid = this.uid;
this.$afs.collection('events').add(event.toDto())
.then(
(success) => console.log(success),
(err) => console.warn(err)
)
}