Categories
Mastering Development

Firestore unwanted saving of repeated entries

I’m trying to store locations nearby me for a test. I ran the following code: var macro_query = db.collection(“cafes”); macro_query = macro_query.where(“name”, “==”, place.name); // check whether name exists console.log(“Checking final query: “, macro_query); // check whether it exists macro_query.get() .then(function(querySnapshot) { console.log(querySnapshot.empty); // returns true if empty, returns false if place.name is already in […]

Categories
Development

Google FireStore – shiftplanning or resource booking – How to query

I need to check if the resource is free during specific time. To know I need to query on following 6 field startdate – greater than operator enddate – less than operator starttime – greater than operator endtime – les than operator isactive – equality operator resource list – array-contains db.collection(entitytype).document(entityid).collection(u’SHIFTPLAN’).where(“isactive”,”==”,True).where(“startdate”,”>=”,22222222).where(“enddate”,”<=”,4444444).where(“starttime”,”>=”,333).where(“endtime”,”<=”,444).where(“daysofweek”,”array_contains”,”ab”).stream() Firestore doesnt allow to […]

Categories
Development

Firebase Cloud Functions CORS

I have a cloud function that reads a file and sends it to the browser. It works when I run locally, and it works sometimes when I run it in through firebase. Other times I get has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response […]

Categories
Development

Error handling in nested async functions in express.js

I am trying to write a micro service to send a message to user to verify his phone number. I am working on the part of the micro service where sending a message to the endpoint with the correct verification code will trigger the code to add his phone number to Firebase. However, I would […]

Categories
Development

How to fetch by id from Firestore?

I have been trying so hard for a couple of hours but it seems so difficult for such a simple thing. i need to fetch by id from Firebase and here is the code that I am using but which is not working: fetch_selected_restaurant = () => { var ref = firebase.firestore().collection(‘restaurants’).where(“res_id”, “==”, “5”).get(); }

Categories
Development

How to implement unique usernames/emails in google firestore

i wrote a rest api that connects to google firestore as a backend. I have a users collection and want to ensure that each user document has a unique username. My first approach was to query the database for a matching document with same username and if it is found, then the user has to […]

Categories
Development

Trying to join one-to-many firebase documents in angular using angularfire

I know this has been asked before but I can’t figure out my scenario from the typical answers provided. In my app I have firebase collection called objectives and a tasks collection that have a one to many relationship. Each objective has a tasks array (filled with the ID’s of the tasks) and each task […]

Categories
Development

Render State.Firestore.Ordered.Data before it is updated

The screenshot is from State.Firestore.ordered.trainings in the console. Let’s say exampleA.js has the following codes of firestoreConnect([ { collection: “trainings”, ]) while exampleB.js has the following codes of firestoreConnect([ { collection: “trainings”, orderBy: [“dateTime”, “asc”], where:[[“trainingName”,”==”,”abc123″]] } ]) When I first loaded exampleA.js, the trainings data are loaded randomly from the database(Firestore), as shown and […]

Categories
Development Firebase

Trying to get firebase data to load into component as state and then be edited

I’m struggling to get get data from Firebase to load into a form wizard. The basic example I am trying right now is just to display some of the firebase data given the collection id. The current error I am receiving is that there isn’t the correct workflow id being parsed into the redux action. […]

Categories
Development Firebase React

Table is no longer updating to firebase, React

I recently change the way I am passing data into my table.I am using a Class to pass data to the component. export function EmployeeClass(data) { if (typeof data.first_name !== “undefined” && data.first_name) { this.first_name = data.first_name; } else { this.first_name = “”; } if (typeof data.last_name !== “undefined” && data.last_name) { this.last_name = data.last_name; […]