Hello Peter,
I sent to you a modified version of your sample app, since they contains some syntax errors, Peter, as the debugger already told you. In addition to the refered syntax error, I find that you are trying to mix AB code and Javascript code: there is no problem to do something like this, but, please, take a look at the External Javascript tutorial of the help file, in order to learn how we can deal with app's global variables, for example, from pure Javascript code.
Take a look at the modified app that I sent to you and try to continue with the work, Peter, and, if you find any specific problem, just post here or open a new thread in this support forum, and, we will try to help you.
Hello Peter,
Probably not all the stuff is already working. For example, you define a "remoteCouch" variable (which I convert to a global variable, so we can use outside where we define it), but, I am not sure if you use that variable after all.
According to the documentation, the database (our "window.App.RootScope.DB" global variable) have the right methods to "sync" to and from the server side.
Apparently that's the place to use the referred "remoteCouch" variable. Maybe you only need to use the right URL in the referred methods: in fact depend on the app that we are developing, we can follow one or one other approach, use (to share it) some variables, etc.
Hello Peter,
Ok. Let me to take a look at this... certainly I think that I can prepare a sample for you with not too much time. Let me to try it and I will back here. :-)
Hello Peter,
I say it's easy... but it's not so easy... it's always the same history: anything that we can develop tends to be complicated... first of all, I don't know nothing about PouchDB, and, even when their Javascript API appear to be more or less easy, certainly, some errors occurs... and then we need lot of time to deep into the documentation of the project in order to know what happen.
Please, take a look when possible at this sample that I prepare for you:
https://www.decsoftutils.com/temp/PouchDB.zip
As you can see, what I try to do is to allows the user to add books into the database, and, at the same time, shown the existing database books into a Report control. All of these can be done without problems: certainly the API of PouchDB is more or less easy to use.
As you can see, the sample is working as expected, however, when I try to use the "sync" method of PouchDB... some error occur... and I can't know if the error is related with the database, the thirdparty server, etc. So I am stuck at that point, and, have no time to continue right now!
I comment the code that try to use the "sync" method, and, as you can see, the sample works, except that, due to the referred error, apparently the database cannot be synchronized with the server side.
Please, Peter, look at the sample, see how it's working as expected, then comment the "UpdateReport" function (used in both the app's view's Show event and the Add Book button Click event) and uncomment the try of the "sync" method code.
Then you can see the error that appear... and may can investigate about that error in the documentation, the thirdparty server, etc. If you have any specific question after that, post it here or open a new thread in this support forum.
Hello again,...
I want to add something that I think I forget. I mention that the PouchDB appear more or less easy, and, it's truth from some point of view, but, that API is also more or less complex (like any other API, of course), so we can / must deal with callbacks, for example, that, depending on our app, we need to use or not.
For example, and, as you can see in the sample, the "sync" method have various events or callbacks that we can / must use. And the same can be said about other methods, like who insert new registries in the database: this callbacks have their own arguments, etc. We can or must use that callbacks, arguments, etc., in order to properly work with the database.
We can't expect, for example, that everything work like expected, so we must take care about the available errors callbacks, the available error codes, etc., in order to assert that the app's user is informed if a registry can't be inserted, if we can't sync to the database, etc., etc. It's a question of time of work, to study and finally handle the PouchDB API, and also how to present or require the user's input from AB, etc.
So take it with time, Peter. :-) And, of course, don't hesitate to post in this forum if you have some specific problem.
No problem! I am sure that finally you can got it. :-)
Hello to all,
You touch a good point, Paolo. Honestly I don't see that the version that we are trying is not the latest release. Trying with the latest release, certainly I can note a couple of things:
1º Apparently the library don't work in Internet Explorer 11, that is, don't work in the internal AB debugger, since it's based in Internet Explorer 11.
2º However, the stuff works as expected in Firefox, for example, and, trying the "sync" method now, what we get is a different error: apparently the thirdparty server don't set the appropriate CORS permissions.
The error that appear now is different than the first one, but, I am not sure if the thirdparty service can be configured in order to set the CORS permissions than the app needed.
If the above is not possible, probably it's required to prepare a bridge in our own server, which communicate with the thirdparty server: maybe this is not so easy, since I certainly don't know how PouchDB works internally and what is sended to the thirdparty service.
On the other hand, the CORS permissions problem maybe masks another possible errors, that is, once the CORS permissions problem is solved, maybe we get another possible errors, that is, once the connection is allowed. But anyway the CORS permissions problem must be solved firstly.
Hello to all,
I do have a local CouchDB server installed but have been working with IBM Cloudant and it is working on several other downloaded html/js examples that I have downloaded and configured
Are you talking about the "sync" method? That is, certainly the sample that I prepare yesterday works also as expected using the latest version of PouchDB, however, what do not work is the "sync" method... but your HTML sample do not use the "sync" method, if I am not wrong... for that I ask if you already try the "sync" method in an HTML app... which is that finally AB apps are...
Hello to all,
But we are talking now about a different end point or URL. The sample that you link in your previous post uses this URL:
But the above URL is not the same than the used in the previous sample. And that's the point... maybe when you use the thirdparty to create a database, it's a way to configure the CORS permissions, the authentication, etc?
One thing that I note is that if I use the HTTPS protocol with your yesterday sample URL, the error is not related with CORS, but with the authentication...
Hi,
I think that I almost have it but am getting an error and I think that it is because I am a total newbie at AB and need to define CouchDB somewhere?
- In the View/Show code I have added the following line below
- I have created a new button called 'sync' for testing and it calls a function called 'remoteSync'
- The remoteSync function code is:
When I press the sync button, I get the following error in the chrome console:
It feels like I am close but need a small hand. I can send you the version if it helps.
Cheers,
Pete
p.s. I tried temporarily swapping the CouchDB url into the PouchDB url and it does read/write to the remote database so I can connect to it so I just need to get the syncing working.
Sorry, here it is formatted:
Hi,
I think that I almost have it but am getting an error and I think that it is because I am a total newbie at AB and need to define CouchDB somewhere?
- In the View/Show code I have added the following line below 'window.App.RootScope.PouchDB = new PouchDB('books');':
- I have created a new button called 'sync' for testing and it calls a function called 'remoteSync' - The remoteSync function code is:
When I press the sync button, I get the following error in the chrome console:
It feels like I am close but need a small hand. I can send you the version if it helps. Cheers, Pete
Hello to all,
I am not sure if you finally got it or not, Peter?
I have it syncing from the local server to the remote server and back so if I open it up in firefox and chrome, the changes are showing in both browsers. It is still really rough and needs to be updating on db change, deletions etc... but I am on my way. When I have the full crud example working with live time syncing, I will certainly share it. I will let you know if I hit any roadblocks along the way.
My ultimate goal is to develop a mobile app that is offline first and syncs between users that share the same account but for now I am happy with baby steps. Thanks for your help, Pete
Hello Peter,
Well... step by step! On the other hand, I want to ask you a question, because I am curious... apparently we use an URL an no other thing to authenticate in the server side, so, what happen if someone stolen that URL and use it by itself? That is, since we are talking about client apps, anybody can take a look at the source code if they really wanted to do it...
Additionally, I can see that PouchDB can be a good solution in some cases, of course, however, don't forget the "traditional" databases in the server side. Certainly, the only problem here (but not in all the cases, since it's depend on the app that we are developing) is that we need an internet connection to reach the server, but, no more...
I supose you already do it, but, can take a look at the "Database" and the "Login" samples, Peter. Note how the "Login" sample try to be an example of how we can serve private information to an specific user, that is, how we can authenticate an user before send to it any private information.
Hi, Yes I realize that everything that I am doing now is wide open. I plan on creating a new end point in a couple of days. I will be building in authentication as one of my early steps, There is a CouchDB plugin that will help me with this.
So far it looks like PouchDB is going to be a good solution. I am just using IndexedDB for local storage although SqlLite is possible too. The app that I am starting on needs to work without internet connection and 95% of the functionality will work in that mode. I plan on some of the functionality requiring internet connectivity such as chats between users and list synchronizations between users that share the same account. I plan on detecting whether access to the internet exists and if so, that functionality will be conditionally exposed.
It's ok!Thanks for your reply, Peter. :-)
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.
This website uses some useful cookies to store your preferences.