Firestore: Add Custom Object to db

前端 未结 8 2033
庸人自扰
庸人自扰 2020-12-15 05:31

Good Morning,

I tried adding a new created object from this class:

export class Sponsor implements ISponsor {

  title: string;    
  description?: s         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 05:48

    Thx to Fabian Wiles - I got it!

    while firebase could send the data inside your object to the database, when the data comss back it cannot instantiate it back into an instance of your class. Therefore classes are disallowed

    just save an object like this:

    interface Person{
      name: string;
      age: number
    }
    
    var person: Person = { name: 'Toxicable', age: 22} ;
    

提交回复
热议问题