I would like to develop a web application for desktops and I would like to be able to connect it to either Couchbase Server or Couchbase Lite.
I think it is pretty simple to connect to Couchbase Server but I am wondering if it is possible to point the web app to a local Couchbase Lite install and use the REST API
Everything I read seems to revolve around PhoneGap. The Couchbase Mobile stack really sounds like it would suit me. Eventually I want to develop a Web App for use in Desktop Browsers, a desktop app developed in NodeJS and Electron and more basic mobile apps.
Iām thinking of sharing the code so the desktop web app would connect to Couchbase Server and if installed a local Couchbase Lite install via the REST API. The Electron app would connect to Couchbase Lite via REST API.
Desktop Browser talking directly to Couchbase Server (Or would it be Sync Gateway) (Windows/xOS)
Desktop Browser talking to a local install of Couchbase Lite (Windows/xOS)
Desktop Electron application talking to a local install of Couchbase Lite (Windows/xOS)
I was hoping to only write the one set of code to deal with the database. I thought if I used the REST API then common code would be a possibility.
I know I could use PouchDB but if I can sidestep that and use only Couchbase that would be great.
It seems to me that the Couchbase Mobile stack is a useful stack for the Desktop but doesnāt appear to be documented very well if it can in fact be used like that.
to Sync Gateway. Having it talk to a local CBL would be easier and let CBL take care of sync
ā¦ test out the .NET version it should work for you.
PouchDB works 100% with SG but CBL has things like compression of data to/from SG , live database event listeners , ā¦etc . Using CBL will future proof your build as they are designed to work together. and of course its open source so you have options for what fits your needs as far as business critical app needing support.
There are people who do use it as an all-in-one data distribution and delivery method, people who see the āBig Pictureā of CB Mobile. Other are very project focused and wanting CB Mobile to handle a specific need. What specific things are you looking for on the desktop side?
We are developing an offline capable Web app. I initially was going to use PouchDB in the Browser as it was easy to do. Having read up on CBL this would do the job better but Iām not sure it is easy to integrate in a WEB Page like PouchDB.
Can CBL be installed from a web page?
Is there a version of CBL that will install on Mac and Windows.
Are there any examples of how to access CBL from JS?
No. Couchbase Lite is a native library. You can use it in PhoneGap or other apps that package HTML/JS sites into native apps, but not from a regular web page. If thatās what you need, look at PouchDB.
Is there a version of CBL that will install on Mac and Windows.
Yes, if you look at the download page there is a Mac version. And the .NET version can run on Windows (right @borrrden ?)
Iāve been in a similar position and thereās basically no choice but to go with PouchDB. It works since both PouchDB and Couchbase Sync Gateway are based on the CouchDB replication protocol.
Thereās a big downside though, mostly performance when dealing with bulk documents ā CBSG send a āContent-Typeā header which is not compatibile with PouchDB which means it falls back to fetching each document seperately. It can be noticibly very slow for initial sync or any bulk changes. Excessive network chatter is really noticable on mobile browsers too. You also miss out on n1ql queries which really sucks.
My understanding is thereās been a lack of communication between the projects which have resulted in a less than desireable state, but hey, at least it works to some degree.
Make up your own mind if itās worth it (Iāve decided on using it as an intrum solution). Iām hoping with WebAsembly getting closer we may see a port of CB lite core to WebAsemblyā¦ or hey, we may have some fixes in PouchDBā¦
With PWAs (progressive web apps) and āoffline firstā slowly becoming more prvelent I hope CB give this area some much needed attention. Thereās no out-of-the-box solutions which work well so work in this area could potencially lead to huge adoption of CB as the defacto leader in the web PWA/offline space.
We have a mobile app and considering building a web app too. The web app will be using c# / asp.net. Considering weāll have many users signed in at once on the web app whatās the best way to sync data between the Web app (server side) and couchbase?
(We wonāt be storing data or have significantly app code on the client - app will not function offline)
So far I can see two options:
1 - create our own basic sync on the server using a SG listener to populate tables in a relational DB and push data changes from the relational DB back to CB via the SG
2 - have a replication going on the server for each signed in user. Effectively using CBL to replicate user data on separate SQLite dbs one for each user. Of course there will be some sort of data management / caching required for this
Any advice / suggestions / views on what is best to do?
i was under the impression all doc updates/ insertions have to go through the SG. Isnāt that the case? If so, using CB purely as the read-only database offers little benefit
currently indexing is not enabled on our cluster (which I assume is needed for querying?). This was done to ensure we donāt run into unforeseen issues when the cluster was first deployed.
Our mobile app really depends on CB+SG working flawlessly (which has been for a few years now). Ensuring we donāt introduce any instabilities by accessing data directly in CB from the web app is a priority. Obviously there is a bit of extra dev time needed (sync) and some extra costs (secondary relational DB) but I donāt think they will be significant.
With Sync Gateway 2 you can create/update docs directly through Couchbase Server (at last!)
Youāll have to ask in a Server forum about indexing ā¦ I donāt think itāll cause any issues, other than increasing the load on the db server slightly as the indexer runs.
Obviously there is a bit of extra dev time needed (sync)
In my experience (Iāve implemented three replicators by now), sync is a thing that seems pretty easy until you actually implement itā¦ Getting the details right is really tricky.
No, sync is not a topic which can be documented in any sort of meaningful way for a general case. You also will not gain a majority of the information by looking at CBLite code since a lot of the logic is implemented at the C++ level. The C# / Java implementations basically only provide some help on top of that for stuff like opening a connection (in particular, with TLS) and resolving an incoming conflict.