Hi David, I had believed that everything was working although at the time I didn't have enough data in the database to properly test. It turns out that the code didn't pull in all of the data and the solution was to just run the two queries sequentially. The proper working code is as follows if anyone is interested:
The only issue that I have right now is with the returned sort order. Because the orderBy is defined in each query, I end up with two separate and distinct sort orders rather than a consolidated sort order for all returned data. I have a lead on how to fix this issue and will report back here if I find a solution.
I have to say that after a prolonged painful period of trying different solutions for handling the offline first, account synchronized data with both CouchDB/PouchDB and a home grown solution using my own back end and rest services I am finally making good progress with Firebase and the variety of solutions that Firebase offers seems to be a natural fit with AB for developing more complex datacentric apps.
Hi David,
I just needed to focus on it myself a bit. For any other potential Firebase users, what I needed to do to handle 'OR' queries is to run one query and push the query results to the Report.Data. Then run a second query to get the next 'OR' data, assign it to a variable and push variable to the same report. Here is the js code that pulled in any shared notes for my vessel plus any notes that were not shared but were created by my user.
Cheers, Pete
Hi David,
I am making good progress on Firebase/Firestore but have hit a small
obstacle which I am hoping that you may be able to help me with.
When querying the firestore data you can add additional query conditions
(AND) by just adding additional.where statements into the query. However,
Firestore does not currently support (OR) conditions If you take a look at
the code below which runs on view show you can see that I have two
mutually exclusive queries (with one of them commented out right now).
I have found that one solution to the missing OR functionality is to
create two more queries and bind them separately to the UI.(combine the
queries). Here is some code that I ran across:
Any chance you could give me a hand building the syntax to combine the
two queries that are in the first code block above?
Thanks!
Pete
Thanks, that worked perfectly. I haven't seen blockUI.stop(); before. Is this in the documentation somewhere and are there other js equivalents of AB functions or do I need to just Google angular js functions? I will start a new thread for the next challenge.
Pete
Hi,
When syncing and displaying the list of notes in the Notes view I have the following code on view show:
What I am trying to do is to block the app while the data is being retrieved and unblock it as soon as it is displayed. Depending on where I place UnblockApp it will either instantly unblock it as soon as it blocks it or it won't unblock it at all. Could you please let me know how I need to handle this to get it to unblock it at the right time?
I guess that yesterday must have been too long a day, I could have sworn that this was the first thing that I tried. It is working properly now so maybe I had a syntax error.
Anyway, thanks once again.
Pete
Hi,
Quick question. When adding a record to the database I use the following code
In order to use user data rather than hard coded data I want to push the input field values into the js function but am having a problem because they need to be inside quotation marks in order for the script to access them but being inside the quotation marks makes it use whatever I put in there as a string. Is there a trick to this?
David, thank you very much, it works like a charm. Now on to updating and deleting, hopefully I won't need to bother you again for a bit.
Cheers,
Pete
Hi, I modified the code as follows:
When the view loads it doesn't show any errors in the Firefox console but nothing is showing in the Notes_Report report. This makes me wonder whether I have used the wrong html in the report object?:
[Record.Title]'br'[Record.Note]
|
Hi again,
In looking at the returned data, I believe that I should just be able to treat it as an array using ArrayConcat? If so, presumably I would need to modify console.log(doc.id, " => ", doc.data()); in the code above and replace it with something that sets Notes_Report.data?
I will email you the ab file.
Okay things are going much more smoothly now that I know not to test in the internal browser. On view load of the notes view I have placed the following code:
Here is a screencap of the browser console:
Hi, I am just adding a few more records then I will start on pulling the data in and report back with what I am dealing with and any errors received.
Hi, Here is a good explanation of the data model for firestore: https://firebase.google.com/docs/firestore/data-model
Okay, so that is the first answer. It worked fine in Firefox and wrote the data to the database and is visible in the firebase console. I will now connect the script to the input fields and create several records and then we can see if we can get the records displaying in a report object.
Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.