How to write data to firebase by Ionic without deleting what is already recorded?

0

My Create method is like this

create(user: User, uuid: string): Promise<void> {
return this.db.object('/users/${uuid}')
  .set(user)
  .catch(this.handlePromiseError);
}

And my User class is like this

export class User {

public $key: string;

constructor(
    public name: string,
    public username: string,
    public email: string,
    public photo: string
) {}

}

But when I write to the firebase, the id goes undefined and when I write another data it overlaps the first one and exits.

    
asked by anonymous 12.08.2018 / 22:05

1 answer

0

Try to make a push() :

create(user: User): Promise<void> {
return this.db.object('/users')
  .push(user)
  .catch(this.handlePromiseError);
}
    
13.08.2018 / 12:37