Sails.JS or Loopback for Electron App - javascript

I am developing a image capture/storage software for school photographers that uses an angular front-end using electron to make it a native cross-platform desktop app. The app will need to have online and offline access. I will run a database on the client machine while offline and when online access is obtained it will sync to a cloud based database. In the future I want to be able to have the option for enterprise customers to run the application on premise and link to their own databases as well.
I was looking into using either Sails.js or Loopback to do this. Do you think one of the frameworks would be better for my particular use case? I would assume that both frameworks would be able to sync the offline data from multiple clients to the master cloud database using transactions easily? Any input you have would be appreciated! Thanks
(Also would react and redux be a better option for the font-end with electron opposed to using angular?)

Deciding which one suits you best is your call, but technically speaking Loopback can do what you need.
The offline/online sync is referred as isomorphic Loopback. Basically, you can run loopback client-side in offline mode, and when you get a connection it will sync with the remote server (that, ultimately, decides if the local data is accepted or not, depending on access control, validation, etc). There is an example repository. Be aware that this functionnality is still considered experimental.
Transactions are supported by some database connectors but not all of them. You can find the documentation here.

Related

Web vs. Mobil Development: data storage

Curious is it possible to store data / records in web development permanently in browser?
I am developing native apps for iOS, and want to understand how web / javascript works.
Usually when app in native development is downloaded first from App Store and first it is launched, client fetches a lot of data from server, and afterwards at next launches when app is running only record changes moves back and forth. Is it possible these kind of data transfers in web development?
In iOS development Core Data is kind a of a ORM local database, on which JOIN operations can be performed. Is it any local database on web development that provide JOIN like operation?
Yes, there are several mechanism for storing data in browser. Check this out : https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
There are of course simpler solutions as well, such as localStorage. Websql is interesting too, although it is deprecated.
Of course, there are ORMs for client side storages as well, such as http://couchdb.apache.org
Web SQL provides a local database that can be queried using SQL. But not all web browsers may support this feature.
You can check the support here: http://caniuse.com/#feat=sql-storage
You can also store data locally using local storage, but this method does not use SQL.

Using a JS framework for developing a database client application?

Requirement:Using a JS frameworks and readily available UI elements to develop a database application (which would connect to databases the user wants to connect to using jdbc, and do some drag-and-drop SQL query building etc. and similar functionality)
I understand that I would need some parts of it needs to be residing in a web server. Since not all the users' databases (local, intranet) could be accessible from a central server where I run my application, I am thinking I would need to bundle the server also (apache tomcat) with my application. Is there any simpler tools/methods to architect this, keeping the UI in HTML5/JS?
Since you did not mention any limitations on the technology or framework to be used, see if you can use this.
MEAN -- MongoDB, Express, Angular and Node.
http://mean.io/#!/

PostgreSQL connection via javascript

I am searching for a way to connect to postgresql directly in the browser. Im trying to utilize nodejs and browserify but have had no luck so far with the bundling. Whenever I compile a script that contains a
require('pg')
it specifically states in the browser:
Cannot find module '/node_modules/pg/lib/client'
the browser tells me afterwards that he is not able to find the modules that pg requires. Maybe i need to bundle pg with browserify before ?
I appreciate if somebody has an idea on how to work on this or even a suggestion how I could connect via javascript to pgsql.
While some node modules may be generally reusable to some degree in a web browser, most take advantage of Node.JS specific features or drivers and cannot work in any web browser. A case like a Postgresql package is a perfect example, as it requires many functions simply not present in a web browser.
If you look at the APIs of Node.JS (http://nodejs.org/api/), these APIs are not available in the browser (some could be emulated, but many are file system, low level sockets, binary modules, etc.).
If you want to use Postgresql, you'll need to build a web server layer, and expose an API of your own (likely a RESTful style api) and call the web services to perform the database actions you want to use. You could look at using Connect or Express to make writing the web service layer more convenient.

How to connect to MySQL from JavaScript?

I know that for connecting to the database from JavaScript I need to mention the database credentials in plain JavaScript code. Therefore for a online application that would be a huge security risk. But in my case I want to write a small JavaScript application which is stored locally. So the credentials won't be shown to the world but just to the user I give the application, which is acceptable for me.
The motivation behind this is that I want to connect to an online database without a running PHP server, just from a JavaScript embedded in the local page. My goal is to provide an application that can be run by the user without the need for PHP and a server, except the database server. It's similar to a desktop application but running in the browser.
How can I connect from JavaScript to an online MySQL database? All other similar questions I found on Stack Overflow advices the thread starter against this usage for good reason but hadn't answered the question.
I heard that connecting to MySQL from JavaScript would be impossible. But how do, say, Windows 8 Metro Apps written in JavaScript handle that issue?
A backend repeater is always needed. For this issue you can set up a light-weight server that forwards your database accessing request to mysql server using, say node.js.
If you are focussing on a specific web browser, maybe you'll find a workaround. But if you're thinking on a local application independent from the user agent, you should follow the standards to reach a predictable behavior (or at least the best approach). In the W3C standards you have two options for storage:
Web Storage API: you're limited to key-value storage, but is very well supported.
Indexed Database API. I've no experience with it, but it's supported.
If you're not to limit the user context to a restricted machine and user agent, you can start with standard storage solutions as mentioned above and then enhance your app for more advanced browsers (perhaps even with MySQL!), as recommended in Progressive Enhancement

How does node.js handle authentication/user systems?

I come from Django's framework, and it has built in "user" system. It takes care of all the registrations, passwords, logins, etc.
Does Node.js have this?
You may want to browse through the packages on the node package manager (npm) registry for NodeJS extension modules that can be combined to enable you to authenticate users, talk to external user management systems, etc. For example, the node-http-digest extension for HTTP digest authentication.
I reviewed the documentation and found no user management system.
node.js is a JavaScript server where-as django is an MVC with built-in socket utilities.
Try to look at connect and express node.js modules. Namely express (which is built on top of connect) can be "compared" with Django's funcionality.
I know this is an old thread but wanted to share this link in hopes it can help others who come across this question.
Checkout Drywall; A website and users system for Node.js
http://jedireza.github.io/drywall/

Categories

Resources