google-cloud-firestore

How should I structure Firestore documents with a large number of docs needed to be read each time

谁都会走 提交于 2020-01-11 13:46:05
问题 I have a list of service that each have a number of fields that are structured like this Service1* ServiceID* NetID* Country* price* xxx* xxx* 10 fields in total* Service2* ServiceID* NetID* Country* price* xxx* xxx* 10 fields in total* I have arranged currently where each service is its own document for a total of 1,180. However when a user visits my site and wants to select a service, the server would fetch all 1180. With just 100users firebase would reading 100k docs. I was thinking of

What relationship between firestore snapshotlistener's lifecycle and pricing?

梦想的初衷 提交于 2020-01-11 13:35:08
问题 In my activities, I have a list of strings which represent firestore documents to which I want to attach snapshot listeners. I use Acivity - ModelView - Repository structure. In the acitivity's onCreate, I ask ViewModelProvider for the appropriate ViewModel. In the ViewModel constructor, I make a call to get a repository (as per the "Android room with a view" tutorial"). My repositories are in charge of attaching firestore listeners and sync the online data into my local DB (android room). I

Function DocumentReference.set() called with invalid data

半腔热情 提交于 2020-01-11 13:19:10
问题 I'm trying to upload an image and a title from an angular website to firestore. This is my template. <form #form="ngForm" autocomplete="off" (submit)="onSubmit(form)"> <div class="form-group"> <input type="text" name="title" id="title" #title="ngModel" [(ngModel)]="service.timetable.title"> </div> <div class="form-group"> <input hidden type="text" name="id" id="id" #id="ngModel" [(ngModel)]="service.timetable.id"> </div> <div class="form-group"> <input hidden type="text" name="imgurl" id=

How to know if query doesn't return documents

空扰寡人 提交于 2020-01-11 12:13:08
问题 How can I know if docs is empty? I can't do len(docs) docs = query.stream() for doc in docs: // do something I need to know if there is no document that matches the query Thank you! 回答1: Since stream() returns a generator, there won't be a trivial way to determine if it is empty without actually reading it. By far the simplest solution would delay knowing until after you are past the loop. Something like this: docs = query.stream() stream_empty = True for doc in docs: stream_empty = False #

Firestore / React is unsubscribe necessary in componentWillUnmount

萝らか妹 提交于 2020-01-11 10:43:57
问题 I have a component that is at a particular route: <Route path='/route-path' component={MyComponent} /> In this component all of my firestore listeners are created in componentDidMount like so: componentDidMount() { var unsubscribe = db.collection(name) .where("query", "==", false) .onSnapshot((querySnapshot) => { // do something }) } Is it necessary to unsubscribe this listener if the route changes? Something like: componentWillUnmount() { unsusbscribe() // from componentDidMount } or is this

Email: [Firebase] Client access to your Cloud Firestore database expiring in X day(s)

ⅰ亾dé卋堺 提交于 2020-01-11 09:34:07
问题 I got an email that indicates I was developing in "test mode", but that it left my database completely open to the internet. The default rules I initially accepted look like this: rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { // This rule allows anyone on the internet to view, edit, and delete // all data in your Firestore database. It is useful for getting // started, but it is configured to expire after 30 days because it // leaves your app open to

Managing the Android back stack and listeners with Firestore for optimizing document reads

僤鯓⒐⒋嵵緔 提交于 2020-01-11 07:44:21
问题 I have activity A and activity B in Android. In activity A there are a FirestoreRecyclerAdapter and a FirestoreRecyclerOptions object, which update in realtime a RecyclerView . I start activity B from a button in activity A, but I do not finish Activity A, so that when returning to Activity A I do not need to read again all documents already previously loaded within my recyclerView. However, if I start a new intent from activity B to activity A, what happens to the Firestore listener in the

Why is not the my listeners hit here in this Firestore set

不羁岁月 提交于 2020-01-11 07:28:10
问题 I have this strange thing where OnSuccessListener or OnFailureListener stopped being called. Everything works ok but when I turn of mobile data and Wifi non of the OnSuccessListener or OnFailureListener is being called. If I put a breakpoints on the below code ref.set(update)..... the breakpoints are indeed hit but non of the OnSuccessListener or OnFailureListener fires Map<String, String> update = new HashMap<>(); update.put(ByteData.DATA, data); DocumentReference ref = firestore .collection

Why is not the my listeners hit here in this Firestore set

强颜欢笑 提交于 2020-01-11 07:28:06
问题 I have this strange thing where OnSuccessListener or OnFailureListener stopped being called. Everything works ok but when I turn of mobile data and Wifi non of the OnSuccessListener or OnFailureListener is being called. If I put a breakpoints on the below code ref.set(update)..... the breakpoints are indeed hit but non of the OnSuccessListener or OnFailureListener fires Map<String, String> update = new HashMap<>(); update.put(ByteData.DATA, data); DocumentReference ref = firestore .collection

Can we not query collections inside transactions?

对着背影说爱祢 提交于 2020-01-11 04:37:07
问题 Looking at https://firebase.google.com/docs/reference/js/firebase.firestore.Transaction I see four methods: delete, set, get, update. I was about to construct a lovely little collection query and pass it to .get, but I see the docs say that .get "Reads the document referenced by the provided DocumentReference ." It appears this means we cannot get a collection, or query a collection, with a Transaction object. I could query those with the query's .get() method instead of the transaction's