angularfire2

Is possible query an !equalTo: null on Firebase?

房东的猫 提交于 2019-12-12 18:35:33
问题 I'm using this query to verify if data exists on my Firebase (using AngularFire2) let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: null } }); Works pretty fine, but i also need to make an inverse query. Like this let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: !null } }); The problem is. This second query, only returns if the value is TRUE , i'm storing a TIMESTAMP on /driveruid

Observable Confusion

谁都会走 提交于 2019-12-12 18:28:18
问题 I am using Ionic2 with AngularFire2 . I am also making use of a rxjs Observable . I have the following code: findChatsForUid(uid: string): Observable<any[]> { return this.af.database.list('/chat/', { query: { orderByChild: 'negativtimestamp' } }).map(items => { const filtered = items.filter( item => (item.memberId1 === uid || item.memberId2 === uid) ); return filtered; }); } and deleteChatsAndMessagesForUid(uid: string): Promise<any> { return new Promise<any>((resolve) => { let promiseArray:

AngularFire2 nested *ngFor Array within Array… but Firebase doesn't have arrays…?

强颜欢笑 提交于 2019-12-12 15:36:33
问题 I'm using AngularFire2, trying to get lists out of lists. A nested *ngFor within an *ngFor doesn't show on the view... app.componnent ... constructor(private _af: AngularFire) { this.lists = this._af.database.list(this._API_URL); } ... app.component.html <div *ngFor="let list of lists | async"> {{sublist.name}}<br/> <!-- I can see you --> <!--******* I can't see you **********--> <div *ngFor="let rootword of list.rootwords"> {{rootword.word}} {{rootword.total}} </div> </div> Example of

Firebase firestore collection count with angularFire 2

廉价感情. 提交于 2019-12-12 14:29:59
问题 I want to get the total number of the documents that exist in firestore. I don't want to get the data only the total number of inside Products collection I have 200.000 items is that possible with Angular 4-5, not angular.js Can someone expert tell me how I can achieve that ?? My code so far and is not work get_total_messages() { this.messages_collection = this.afs.collection<MessageEntity>('messages'); return this.messages_collection.snapshotChanges(); } End this is how I try to get the data

Firestore: Serve cached datas first

泄露秘密 提交于 2019-12-12 13:08:36
问题 Firestore can handle offline persistence but it doesn't seem to load cached datas first. Is that possible ? The app perf would seem much better if the local datas were loaded first. If not possible, is there an easy way to get the local datas manually so I can do an Observable merge and load cached datas first. Thanks a lot EDIT: I'm using angularfire2 with Ionic 3. I'm expecting an offline first behavior from Firestore. Since valueChanges() returns an Observable, I think it should first emit

Convert CollectionReference in AngularFirestoreCollection<T> or Observable?

邮差的信 提交于 2019-12-12 10:24:06
问题 My method is returning a CollectionReference . However, this method used to return a AngularFirestoreCollection<myObj> before I converted it to Observable<myObj[]> to work with arrays. humanCol : AngularFirestoreCollection<Human>; humanObersArray: Observable<Human[]>; constructor(private db: AngularFirestore) { } Before I was using this way. Work greats to fetch all data. buildHuman(): Observable<Human[]> { this.humanCol = this.db.collection('path'); return this.humanObersArray = this

Guard always return true

空扰寡人 提交于 2019-12-12 07:03:53
问题 I have two pretty similar guards in angular app. First of them checking is User logged in: // isUser guard export class isUser implements CanActivate { constructor( private fireAuth: AngularFireAuth, private router: Router ) {} canActivate( next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { return this.fireAuth.authState.pipe( take(1), map(authState => !!authState), tap(auth => !auth ? this.router

return user.uid onAuthStateChanged

瘦欲@ 提交于 2019-12-12 06:36:49
问题 I have small function and it works when I look in console: returns user.uid in console but I want to return uid to use in other function newUserUid() { return firebase.auth().onAuthStateChanged(function(user) { if (user) { console.log(user.uid); } }); } I want to function return uid like this: ewfwe3423sdfsdakmasd 回答1: You need to subscribe to the auth state. You are using the JavaScript SDK inside an Angular 2 app, use the AngularFire2 SDK instead. import { AngularFireAuth } from

Angular 2 route restriction with AngularFire 2 Auth

♀尐吖头ヾ 提交于 2019-12-12 05:17:48
问题 I'm trying to restrict routes to be available only to authenticated users. So far I've added a service call in every route component constructor to check if the user is logged. If not, you get redirected to the login route(index): logCheck(){ this.af.auth.subscribe(user => { if(!user){ this.router.navigate(['']); } }); It works. But I'm not sure if using the constructor of each route component for this is the correct way of doing things, because you are actually loading the component before

AngularFire Observables / Subscribe - Not Setting Class Variable in Same Scope

偶尔善良 提交于 2019-12-12 04:38:18
问题 I'm building an Ionic app using Firebase, and therefore AngularFire2. In Angularfire2 you can authenticate, but it's an observable and have to subscribe to get the user object. The problem is that I can't seem to set this.user = user because it doesn't seem like .subscribe is in the same scope. Here's an example, I have a auth.ts and an app.component.ts . In my service, I authenticate, auth.ts export class AuthService { // user: Observable<firebase.User>; user: object = { displayName: null,