firebase

How to display the exact number of items from a Firebase Database in a ListView using FirebaseListAdapter with Android?

不羁岁月 提交于 2021-02-16 18:27:06
问题 I have a very simple Firebase Database which looks like this: This is my model: public class ShoppingListModel { private String shoppingListName; private Map<String, String> usersMap; public ShoppingListModel() {} public void setShoppingListName(String shoppingListName) {this.shoppingListName = shoppingListName;} public String getShoppingListName() {return shoppingListName;} public void setUsersMap(Map<String, String> usersMap) {this.usersMap = usersMap;} public Map<String, String>

Firebase Database setValue: or removeValue failed: permission_denied iOS

a 夏天 提交于 2021-02-16 16:16:11
问题 I'm trying to write data to Firebase Database but I keep receiving the following error when my saved button is pressed. 2016-12-02 11:09:42.548 StartupNow[1482:60415] [FirebaseDatabase] setValue: or removeValue: at /test/-KY-VpLZWbp4vjF3BpMk failed: permission_denied Things I've tried: I've made sure my .read and .write rules were set to true in my console, reconnected my savedButtonPressed button, and wrote the Firebase reference in a function and called it in my savedButtonPressed() method.

Wait for Firestore queries to complete

非 Y 不嫁゛ 提交于 2021-02-16 15:28:28
问题 I am currently trying to run multiple queries in firestore and want to wait for them to all complete before executing the next code. I've read up on several possible avenues but I have yet to find a good Android example. public HashMap<String,Boolean> multipleQueries(String collection, String field, final ArrayList<String> criteria) { HashMap<String,Boolean> resultMap = new HashMap<>(); for (int i = 0; i < criteria.size(); i++){ final int index = i; db.collection(collection).whereEqualTo

How to retrieve data from firebase where the value of a date is 1 month ago from current date

前提是你 提交于 2021-02-16 14:28:07
问题 SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm"); Calendar c = Calendar.getInstance(); String date = sdf.format(c.getTime()); i used this code to get the current time. but i want to get all data from firebase 1 month ago. what i must add the code? i used this code to retrieve all without compare anything mDatabasetamu.orderByChild("tglkeluar").equalTo(date).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot

Firestore Query Properties with special characters

和自甴很熟 提交于 2021-02-16 14:24:04
问题 I've a collection with contacts with a structure like: name: 'XPTO' emails: { susan@xpto.com: 'Susan', fred@xpto.com: 'Fred' } But the query will not return result: db.firestore().collection('contacts').where('emails.susan@xpto.com', '==', 'Susan').get().then(... Because of the dot at "susan@xpto.com" How to escape the dot? I've tried `` and [ ] and didn't work. 回答1: The documentation that suggests you should escape fields using backticks is actually not correct. It's in the process of being

How can I order the documents in Firestore?

◇◆丶佛笑我妖孽 提交于 2021-02-16 14:19:33
问题 How can I order the documents in Firestore? It looks like Firestore lists documents in alphabetic order by the ID I let Firestore automatically create. But I don't want that. I just want to see my newly added document added as the last document in the collection. How do I do that? Should I create my own alphabetic ID's? Example of my collection in Firestore: 回答1: Firestore is meant to scale massively. At that scale, it doesn't matter what order the documents appear in the console, because the

Filter location GeoPoint in distance radius - Firestore

房东的猫 提交于 2021-02-16 14:10:42
问题 How to search the Firestore database for the location Latitude and Longitude within a defined distance radius. Sample Database: COMPANIES - COMPANY 1 --Lat: 12345 --Long: 6789 - COMPANY 2 --Lat: 457851 --Long: 654214 - COMPANY 3 --Lat: 12345 --Long: 6789 - COMPANY 4 --Lat: 12463 --Long: 65487 Note: At Real Time I had the option to use GeoFire, but at Firestore I did not find any way. How could you go through the database and find the Companies according to your Location, within a radius of

Filter location GeoPoint in distance radius - Firestore

老子叫甜甜 提交于 2021-02-16 14:10:13
问题 How to search the Firestore database for the location Latitude and Longitude within a defined distance radius. Sample Database: COMPANIES - COMPANY 1 --Lat: 12345 --Long: 6789 - COMPANY 2 --Lat: 457851 --Long: 654214 - COMPANY 3 --Lat: 12345 --Long: 6789 - COMPANY 4 --Lat: 12463 --Long: 65487 Note: At Real Time I had the option to use GeoFire, but at Firestore I did not find any way. How could you go through the database and find the Companies according to your Location, within a radius of

Finding an UID by email in Firebase

做~自己de王妃 提交于 2021-02-16 14:07:22
问题 I first attempted to instantiate each user in the database like so: emails : { email: "jerry@gmail.com" { uid: "x" } } I quickly found out that I can't store an email because it has an @ and . . I was originally going to do an user look up like so: func userLookUpByEmail (email: String) -> String { var userID: String = "nil" ref.queryOrderedByChild("emails").queryEqualToValue(email).observeSingleEventOfType(.ChildAdded, withBlock: { snapshot in if snapshot.value != nil { print(snapshot.value)

How to avoid loops when writing cloud functions?

两盒软妹~` 提交于 2021-02-16 13:36:49
问题 When writing event based cloud functions for firebase firestore it's common to update fields in the affected document, for example: When a document of users collection is updated a function will trigger, let's say we want to determine the user info state and we have a completeInfo: boolean property, the function will have to perform another update so that the trigger will fire again, if we don't use a flag like needsUpdate: boolean to determine if excecuting the function we will have an