本文整理汇总了TypeScript中@angular/fire/firestore.AngularFirestore类的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFirestore类的具体用法?TypeScript AngularFirestore怎么用?TypeScript AngularFirestore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AngularFirestore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateUser
private updateUser(data: any): Promise<void> {
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${data.id}`);
return userRef.set(data, { merge: true });
}
示例2: constructor
constructor(private db: AngularFirestore) {
this.rodadas = db.collection(config.rodadaDB);
}
示例3: constructor
constructor(private db: AngularFirestore, private jogoService: JogoService, private cookieService: CookieService) {
this.jogadores = db.collection(config.jogadorDB);
}
示例4:
col<T>(ref: CollectionPredicate<T>, queryFn?): AngularFirestoreCollection<T> {
return typeof ref === 'string' ? this.afs.collection<T>(ref, queryFn) : ref;
}
示例5: constructor
constructor(private afs: AngularFirestore) {
this.notesCollection = this.afs.collection('notes', (ref) => ref.orderBy('time', 'desc').limit(5));
}
示例6: oAuthLogin
private async oAuthLogin(provider) {
const loginAction = await this.afAuth.auth.signInWithPopup(provider);
const userRef = await this.afs.doc(`users/${loginAction.user.uid}`).valueChanges().pipe(first()).toPromise();
const updateObject: any = {
id: loginAction.user.uid,
displayName: loginAction.user.displayName,
emailVerified: true,
email: loginAction.user.email,
creationTime: loginAction.user.metadata.creationTime,
lastSignInTime: loginAction.user.metadata.lastSignInTime
};
if (!userRef) {
const registrationData = await this.applicationService.getAppData().toPromise();
updateObject.assignedRoles = {
admin: registrationData.registration && registrationData.registration === 'admin',
editor: registrationData.registration && registrationData.registration === 'editor',
subscriber: registrationData.registration && registrationData.registration === 'subscriber'
};
}
return this.updateUser(updateObject);
}
示例7: loginJobs
loginJobs() {
const user = this.afAuth.auth.currentUser;
const userInfo: User = {
uid: user.uid,
displayName: user.displayName,
email: user.email,
phoneNumber: user.phoneNumber,
photoURL: user.photoURL,
logged:true
}
this.afs.
collection<User>(`users`)
.doc(user.uid)
.set({ ...userInfo })
.then(res => {
console.log(res);
}).catch(err => {
alert(err)
})
this.storage.set('user', userInfo)
this.events.publish('user:login', user)
}
示例8: savePhoto
private async savePhoto(path: string, displayName: string, uid: string, lexeme: string, dictionaryId: string) {
try {
// tslint:disable:max-line-length
const storagePath = 'https://anet-photo.appspot.com/urlfull/talking-dictionaries-' + (environment.production ? 'alpha' : 'dev') + '.appspot.com/' + path;
const result = await this.http.get(storagePath, { responseType: 'text' }).toPromise();
const gcsPath: string = result.replace('http://lh3.googleusercontent.com/', '');
const pf: IPhoto = {
path,
gcs: gcsPath,
ts: firestore.FieldValue.serverTimestamp(),
cr: displayName,
ab: uid,
};
const entryDoc = this.afs.doc(`dictionaries/${dictionaryId}/words/${this.entry.id}`);
await entryDoc.update({ pf });
this.snackBar.open(`Photo uploaded for ${lexeme}`, '', { duration: 3000 });
} catch (err) {
this.snackBar.open('Error Uploading Image. Please email Jacob image name and lexeme.', 'OK',
{ duration: 20000, panelClass: 'snackbar-error' });
}
}
示例9: updateJogo
updateJogo(id, update) {
this.jogosDoc = this.db.doc<Jogo>(`${config.jogoDB}/${id}`);
this.jogosDoc.update(update);
}
示例10:
this.dictionariesService.currentDictionary.pipe(take(1)).subscribe(dictionary => {
this.afs.collection(`dictionaries/${dictionary.id}/writeInCollaborators`).add(writeInCollaborator);
});
示例11: getNote
getNote(id: string) {
return this.afs.doc<any>(`notes/${id}`);
}
示例12: switchMap
switchMap((dictionary) => {
return this.afs.doc<DictionarySettings>(`dictionaries/${dictionary.id}/config/settings`).valueChanges();
})
示例13: deletejogador
deletejogador(id, jogoId) {
this.jogadorDoc = this.db.doc<Jogador>(`${config.jogoDB}/${jogoId}/${config.jogadorDB}/${id}`);
this.jogadorDoc.delete();
}
示例14: updatejogador
updatejogador(id, update, jogoId) {
this.jogadorDoc = this.db.doc<Jogador>(`${config.jogoDB}/${jogoId}/${config.jogadorDB}/${id}`);
this.jogadorDoc.update(update);
}
示例15: setJogo
setJogo (jogoId) {
this.jogadores = this.db.collection(config.jogoDB).doc(jogoId).collection(config.jogadorDB);
}