google-cloud-firestore

Firebase Firestore order by not working

旧街凉风 提交于 2021-02-07 12:37:18
问题 I am learning about Firebase Firestore through official documentation. I was trying following code. Notifications are added using add() method of firestore. FirebaseFirestore.getInstance().colRefNotifications() .orderBy("timestamp", Query.Direction.DESCENDING) .get() .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() { @Override public void onSuccess(QuerySnapshot documentSnapshots) { if (!documentSnapshots.isEmpty()){ listNotifications.clear(); recyclerViewNotification

Creating Empty Documents in Firestore

荒凉一梦 提交于 2021-02-07 12:32:51
问题 I understand that empty documents within collections are removed automatically by the system in Firestore. However, I have a situation now where the name of the document serves a purpose. I have a collection named usernames, and within this, many documents with the ID being the username. For instance, usernames/bob_marley is what I might see in the database. The problem here is that, since the documents do not have any fields in them, they get removed automatically thereby defeating the

Firestore: What is the best way to populate array of ids with its content?

时间秒杀一切 提交于 2021-02-07 09:57:56
问题 I have array of objects containing users Ids. const userIDs= [{key: 'user_1'},{key: 'user_2'}, {key: 'user_3'}]; I want to fill it with user data from cloud firestore. const userIDs= [ {key: 'user_1', name: 'name1'}, {key: 'user_2', name: 'name2'}, {key: 'user_3', name: 'name3'} ]; What is the fastest and less pricey way of doing it ? This is my current way of doing it. const filledUsers = []; for (let index in userIDs) { const user = Object.assign({}, concatUsers[index]); const snapshot =

Firestore - adding object with an array

旧街凉风 提交于 2021-02-07 08:44:57
问题 killing myself with this thing in here all day, I'm having two classes Department and Articals : export class Department { articals?: Artical[]=[]; moms?: number; id?: string; constructor() { } } and: export class Artical { moms?: number; price: number; name?: string; constructor() { } } like You can see departments contains an Array of 'Articals' so I am building new Department with new articals(and their properties) and trying to add it to fireStore with: this.departmetsCollection.doc

Firestore - adding object with an array

久未见 提交于 2021-02-07 08:44:40
问题 killing myself with this thing in here all day, I'm having two classes Department and Articals : export class Department { articals?: Artical[]=[]; moms?: number; id?: string; constructor() { } } and: export class Artical { moms?: number; price: number; name?: string; constructor() { } } like You can see departments contains an Array of 'Articals' so I am building new Department with new articals(and their properties) and trying to add it to fireStore with: this.departmetsCollection.doc

Firestore how stop Transaction?

喜你入骨 提交于 2021-02-07 07:34:18
问题 In transaction I only want to write data if data not present DocumentReference callConnectionRef1 = firestore.collection("connectedCalls").document(callChannelModel.getUid()); firestore.runTransaction(new Transaction.Function < Void > () { @Override public Void apply(Transaction transaction) throws FirebaseFirestoreException { DocumentSnapshot snapshot = transaction.get(callConnectionRef1); Log.d(TAG, callChannelModel.getUid()); if (!snapshot.exists()) { //my code transaction.set

Unable to fetch data from Firebase Firestore in react native

点点圈 提交于 2021-02-07 06:59:10
问题 I am trying to GET data from Firestore but I cannot see data coming. I am building a react-native app. I am using react-native-firebase. I also tried Transactions method from react-native-firebase documentation. But nothing is working. Here' my code: firebase.firestore().collection('users').doc(uid) .get() .then((doc)=>{ console.log(doc) console.log(doc.data().shoppinglist) }) .catch(e => console.log(e)); Console logging .get() gives me a Promise. I am getting the Promise like this: Promise {

Using the reference data type in Firestore Rules

北慕城南 提交于 2021-02-07 06:58:20
问题 I want to define a rule that allows a user only to update his own items and an admin to update all. As uid_of_logged_in_administrator I should be able to update both items/item__1 and items/item__2 - this works. As uid_of_logged_in_user I should be allowed to update items/item__1 but not items/item__2 - this does not. Obviously the problem is I do not know what the data type [ Cloud Firestore references ] represents in rules. I've read through the documentation on rules and been trying

Firebase Project Initialization Error: Cloud resource location is not set for this project

天涯浪子 提交于 2021-02-07 05:12:41
问题 I tried to find a quick answer to this question but couldn't find anything. I am trying to set up an Ionic application to use an existing Firebase project and when running firebase init in the windows console I get this message: Error: Cloud resource location is not set for this project but the operation you are attempting to perform in Cloud Firestore requires it. Please see this documentation for more details: https://firebase.google.com/docs/projects/locations 回答1: The message is actually

How to initialize default values for GeoPoint in a data class

百般思念 提交于 2021-02-05 12:13:42
问题 I'm trying to convert documents to objects from Firestore, but when I create my data class , I dont know how to initialize the GeoPoint with default values as it needs to be declared for an empty constructor data class MapObj(val geopoint:Geopoint) //--> how to initialize it to get an empty constructor The problem relies on this line val obj = snapshot.toObject(MapObj::class.java) Thanks 回答1: The problem is that the Firestore SDK isn't finding a default, no argument constructor for MapObj.