angularfire2

How to save date in Angular as a timestamp to Firestore?

夙愿已清 提交于 2019-12-02 04:37:07
I am trying to save personal info of person with birth date and activation date into Firestore database in Angular; However, passing object with Date() type fields the dates are saved as a string: this.treatment.activationDate = new Date(); // gives such result in firestore with string type // activationDate: "2018-11-16T09:48:51.137Z" Also tried to use server timestamp, but the following method does not return valid value: firebase.firestore.FieldValue.serverTimestamp() Result in Firestore (not allowed to upload images sorry :) ): activationDate: (map) _methodName: FieldValue.serverTimestamp

Why does this firestore query require an index?

不羁岁月 提交于 2019-12-02 03:10:27
I have a query with a where() method with an equality operator and then an orderBy() method and I can't figure out why it requires an index. The where method checks for a value in an object (a map) and the order by is with a number. The documentation says If you have a filter with a range comparison (<, <=, >, >=), your first ordering must be on the same field So I would have thought that an equality filter would be fine. Here is my query code this.afs.collection('posts').ref .where('tags.' + this.courseID,'==',true) .orderBy("votes") .limit(5) .get().then(snap => { snap.forEach(doc => {

Recursive calls to Firestore

依然范特西╮ 提交于 2019-12-02 02:21:57
I have a Firebase Firestore with "Components" as a root collection. Each document (a "Component") in the collection may have an array called "children", with each item in the array being an "id" of another component, essentially, a one-to-many relationship. Since every child is also a component it may also have its own children and so forth. Components Collection Parent 1_Parent (document) │ name: 'Parent' │ id: '1_Parent' └─children (array) ├─1.1_Child_one └─1.2_Child_two First Child 1.1_Child_one (document) name: 'Child One' id: '1.1_Child_one' Second Child 1.2_Child_two (document) │ name:

How do I add client-side attributes to items in a FirebaseListObservable?

两盒软妹~` 提交于 2019-12-02 01:28:53
I'm building a simple chat app backed by this Firebase Database structure: messages: { "-KTjL_oLrKOboa2su2zk": { name: "puf", text: "Look I'm smiling :-)" }, "-KTjNfaNem752ChFBcnC": { name: "puf", text: "And now I'm not smiling" } } I'm using Angular2 and AngularFire2 to generate the HTML. I have a simple list of messages from the Firebase Database in my controller: export class AppComponent { messages: FirebaseListObservable<any[]>; constructor(public af: AngularFire) { this.messages = af.database.list('messages'); } } I want to detect certain conditions in each message and translate that

Firebase Angular2 - how to query and render lists without too much overhead

自作多情 提交于 2019-12-02 01:00:28
问题 In my application I have the following firebase posts structure: posts: { text: ".." meta: {..} user: { id: "user1", username: ".." } } I'm using angularfire2. So, to get all posts posted by specific user, I run the following query: this.userPosts$ = this.af.database.list('/posts', { query: { orderByChild: 'user/id', equalTo: userId } }).map( (posts) => { return posts.map(post => Post.unpack(post)); }).publishReplay(1).refCount(); I've heard that it's not very efficient, since every time

Firebase Angular2 - how to query and render lists without too much overhead

时光怂恿深爱的人放手 提交于 2019-12-01 21:24:34
In my application I have the following firebase posts structure: posts: { text: ".." meta: {..} user: { id: "user1", username: ".." } } I'm using angularfire2. So, to get all posts posted by specific user, I run the following query: this.userPosts$ = this.af.database.list('/posts', { query: { orderByChild: 'user/id', equalTo: userId } }).map( (posts) => { return posts.map(post => Post.unpack(post)); }).publishReplay(1).refCount(); I've heard that it's not very efficient, since every time something changes (even in a single post), the whole list is reloaded and, thus, re-rendered. And since I

Creating an auto complete serach using angularfire2 and firestore?

霸气de小男生 提交于 2019-12-01 20:06:29
Hey im trying to build a simple search function for my web app. there is documentation on how to create it with real time database. What changes do i need to make to make this work on firestore ? this tutorial was taken from here https://angularfirebase.com/lessons/autocomplete-search-with-angular4-and-firebase/ it has a nice video as well :) this is how to make it with real time database : #movies.service.ts import { Injectable } from '@angular/core'; import { AngularFireDatabase, FirebaseListObservable } from ' angularfire2/database'; @Injectable() export class MoviesService { constructor

AngularFire2: Perform 'Joins' on FirebaseListObservables using RxJS .map()

浪子不回头ぞ 提交于 2019-12-01 12:17:46
As stated in another question, I'm developing an Ionic 2 App using Firebase as Backend. I have categories and I have products. Products belong to categories. As it is a "n to m" relationship, products and categories are stored in separate nodes in firebase. I structured the data as follows: Firebase data structure: Categories know, which products belong to them (keys are referenced in "prods" node of each category). Products know, which categories they belong to (keys are referenced in the "prod_cat" node). However, when I list all categories I just know the IDs of the products which belong to

AngularFire2: Perform 'Joins' on FirebaseListObservables using RxJS .map()

北城余情 提交于 2019-12-01 11:16:50
问题 As stated in another question, I'm developing an Ionic 2 App using Firebase as Backend. I have categories and I have products. Products belong to categories. As it is a "n to m" relationship, products and categories are stored in separate nodes in firebase. I structured the data as follows: Firebase data structure: Categories know, which products belong to them (keys are referenced in "prods" node of each category). Products know, which categories they belong to (keys are referenced in the

Angular2 - Change detection not showing unless clicked

萝らか妹 提交于 2019-12-01 04:51:43
I have an component in which you can enter some search terms and it will filter the content using a *ngFor loop. The trouble is when I enter a search term I need to click the screen for the update to take effect visually. Here is the part of the html code in which the loop occurs: <li *ngFor="let item of posts | reverse; let i = index; "> <div class="media" *ngIf="item.doesContainTags(searchTags)"> The code that executes on the input field where you enter the tags to search for is: updateSearchTags() { event.stopPropagation(); // sorter is what is types into the search by tag input field this