I am creating a nodejs app and as per clients suggestion trying to implement it in AmpersandJs. I have installed framework and created application by following documentation &js installation.
The app is running with some sample data
I found that the sample data is coming from ampersand-app module from an index.js file.
But I want to do database connectivity with it -- How should I achieve this? I have Googled but not found any good link for it.
Did &js is good choice to develop application or it is for an specific type of projects?
But I want to do database connectivity with it -- How should I achieve this?
Ampersand.js is running in the browser. If you want to access data stored in a database you have two options:
Request data from a database running on a server somewhere accessible over the network. In this case you want to use the url property of models/collections
Use an in-browser database (maybe you want to have look at pouchdb as API)
Did &js is good choice to develop applications?
Definitely yes!
Related
I have two questions a bit theoretical. I searched in the Internet but I didn't get a clear answer.
My first question:
I would like to develop an app in MEAN stack (Mongo, Angular8, NodeJS server), but I don't want to have a central server connected with the database somewhere and all the clients just connect to it remotely. I want to deploy the whole app (mongo database, server back-end, angular front-end) locally in a standalone pc. Yes, the user would have to activate both database and server services and yes, he would have to use the app through the browser at the localhost address, but I don't want him to be able to see the code. Is it possible or do you have in mind any trick to achieve that?
My second question:
Can I directly link mongo database with the Angular8 code without interfere the NodeJS API's?
I know that my questions are a bit generic, but I am not looking for huge answers, rather if my questions are possible and some tips on how to move on.
For the first question: Your user will always be able to see the compiled code (through the developer console for example) but not the source code of the angular application.
Just trying to spec out a new system. We want to build a mobile app with offline storage using react-native.
We were originally going to use node and create a web api layer that worked with a MongoDB. However after looking into offline storage we found PouchDB. But pouch has to use CouchDB. So we are considering using CouchDb and having a flat db layer with all our business and data logic modelled in the apps.
However there may be some server side things that we need to do (for example pulling other records from somewhere else in the organisation).
So can we deploy a web api using node alongside CouchDb? How would this work? Totally separate or in the same node process?
So can we deploy a web api using node alongside CouchDb?
Yes, of course.
How would this work?
I'm not sure about what solution suites your needs, but one solution is to develop a web app with this tech-stack: NodeJS/Express, CouchDB/PouchDB and ReactJS/MobX. One important point about CouchDB is that, you shouldn't think about it like any other database . Basically, you don't need any server-side code to talk to CouchDB, it can all be done on the client-side with PouchDB. The live sync of PouchDB is extremely convenient at handling offline/online storage. If you're considering ReactJS, take a look at MobX.
I want to connect mongodb server to android application so that i can send data( which is stored online on mongodb ,not locally) to android user. I want to do it through REST api using node.js but couldn't find a way to do it.
Please help.
First of all it's a bad idea to connect to the Database directly. It is possible, but it'a a bad idea.
It's a much better practice to create a web service backend that your app can connect to. This will allow you to implement the business logic on the server. And additionally, you will be able to use not only Android, but iOS, AngularJS and others as clients too.
Generally the most common rest backend architecture looks something like this:
REST BACKEND
I find this way of development to be modular and very well organized.
In short, the API layer only takes HTTP GET and POST methods, and calls the appropriate functions in the Service layer. The service layer holds all of your business logic and calls the DAO layer, and Dao call anb works with the DB.
There's tons of examples for how to build web services, and it's highly dependent on your language of choice for your web tier. There are also tons of examples for consuming web services on Android. You should look it up.
But whatever language you choose the API -> Service -> Dao -> Database scheme should work fine.
If you don't know where to start take a look at Python Flask or Java Spring as good candidates for developing web services. (I use Spring because there is a ton of great documentation on whatever you may need.)
Hope this helps a bit. Good luck!
I would like to know, how to get data from MySQL database to my application without using any REST API or PHP code. I was looking over the internet for the solution for this problem. But they say, you can use php code as REST API and then, can communicate with database. For this purpose, i will need a host and domain. I don't want to use that. Is there any other way to communicate with mysql database. Can i use mysql module of node js in titanium application.
There is no way to have direct connection between your mobile client and MySQL database. To retrieve data from MySQL you need to build application which will receive request from your app, retrieve data from MySQL, process and return it as a response.
If you don't want to build mobile and server application at the same time you can try using Appcelerator Cloud service, which plays really nicely with Titanium SDK and allows you to persist users data.
There are two answers to this problem, depending on your situation:
If Your Data Is Specific to One Device...
If you want to store data locally on one device, and that one device is the only one that will ever use it, then you want to use a SQLite database. This is very commonly used in mobile apps, and is very well documented. If you already have a MySQL database with the schema you want to use, then you could really easily convert it to a SQLite db file.
If Your Data Is Centralized...
If you need to store data remotely, in one central place, that the mobile app can access, then you need to use a remote database.
MySQL is one such option. You say that hosting PHP (which is itself run through something like Apache or IIS) is not something you want to do. But if you can host MySQL somewhere, or run it on a machine that your mobile app can access, then you can also easily host PHP and Apache.
If you don't want to spend money on a domain, then use one of the free dynamic DNS providers, which map a domain name (such as foo.hopto.org) to an IP address. If you don't want to pay for a server, then use your home computer, and keep it on whenever the mobile app needs to access it. There's easy, well documented ways around any of the issues you're having.
Alternatively, as #daniula pointed out, use Appcelerator Cloud Services. Then you can interact with simple objects, and they'll be stored for you in a central server. You can control who can access what data, and more. (Full disclosure -- I work for Appcelerator.)
I have an application on Symfony 1.4 framework. Recently I've started building an app in Node.js.
I need to do some action's response in node and I'd like to set credientals (log In the user) remotely, because some data is dependent on the user's data and I can't omit it.
How can I do this?
I am not sure I completely understood your scenario, but from I grasp you could share the session data (if this is the "user data" the nodejs app needs) between the two platforms (maybe use a common database to store sessions, like Redis) or you could implement a web service or api (REST) to enable communication between the two platforms, if the data is more complex.
Hope my answer was helpful.