現在、このrepos認証https://github.com/codediodeio/angular-firestarterを研究中です。この認証サービスは、著者がたびにユーザー登録とサインをユーザーデータを更新するには、このメソッドを使用してレポでangularfire2:破壊的な更新(set())と非破壊的な更新(update())の違い
このスニペットは、リアルタイムDBにユーザーの名前とメールアドレスを書き込みます。私の側で
//// Helpers ////
private updateUserData(): void {
// Writes user name and email to realtime db
// useful if your app displays information about users or for admin features
const path = `users/${this.currentUserId}`; // Endpoint on firebase
const data = {
email: this.authState.email,
name: this.authState.displayName
}
this.db.object(path).update(data)
.catch(error => console.log(error));
}
私が現在作業しているプロジェクト上記のスニペットを使用してfirebaseにユーザーの詳細を書いています。ユーザーの詳細(電子メールとパスだけでなく)は登録時にのみスニペットを使用しています。登録。
this.db.object(path).update(data)
のラインで
Iドキュメントhttps://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md#api-summary二つの方法を問わず、この.update()
とset()
があり、それは.update()
は破壊的な更新非破壊更新とset()
であることを文書で述べています。私はこの2つを実際に試してみましたが、他のものと同じように動作します。
私は上記で説明したように、登録時にスニペットを使用します。set()
またはupdate()
はどうすればよいですか? 破壊的なものと非破壊的なもの更新、これらの大きな助けとなるものを説明するリンク。