constructor(private af: AngularFireDatabase) { this.items = af.list(`/${TABLE}`).valueChanges(); }
getLastMessage(): AngularFireList<any[]>{ return this.db.list('/messages/last/', ref => ref.orderByChild('time').limitToLast(10) ); }
observePosts() { return this.af.list( this.category(ALL_CATEGORIES) ); }
getCourses(listPath): Observable<any[]> { return this.db.list(listPath).valueChanges(); }
push( path, data ) { return this.db.list('/' + path ).push(data); }
messageIds.map(message => { return this.database.object('/messages/'+message.key) .first() }),
/** * Get post by id * @param key */ getPostById(key: string): Observable<any> { this.postRef = this.db.object(`posts/${key}`); this.post = this.postRef.valueChanges(); return this.post; }
readUsers(): Observable<User[]> { return this.afDatabase.list('users').map((snapshot: any[]) => ( snapshot.map(userValues => new User(userValues)) )); }
readUser(uid: string): Observable<User> { return this.afDatabase.object(`users/${uid}`).map((snapshot: any) => ( new User(snapshot) )); }
this.posts.push(postObject).then((item) => { this.db.object('/posts/' + item.key + '/entityKey').set(item.key); });