I am trying to understand how node.js works.
1) I would like to store data, but I don't know which method is the faster:
-using sql
-using json files (if this is a good solution have you got a tutorial for best practice)
2) A multilang website, is it a good solution to store translations in json files or is there a best practice?
Handling JSON is faster with JavaScript than SQL because it's native so I would always use JSON over any other data format with node.js wherever possible. In terms of storing JSON, you can go for NoSql solution eg: MongoDB or CouchDB.
This link will get you started on MongoDB.
There are many options for multilingual websites, you can use Google translate or tons of other plugins depending on your requirements. If you want to store literal translations then NoSql DB will work fine. In terms of best practices, refer to this question.
For Translation, you should ideally use internationalization module, whatever language or framework it is. In Node.JS you have i18n-node for internationalization. Your translation will be stored in JSON files. There are also other modules which can store your traslations in db.
Related
Background
I am building an Angularjs app and have added express and mongodb to the app already but when looking for some other back-end tools I came across firebase.
I'm just a little confused as to how it all fits together and would appreciate some experienced users input on it.
Question
Does firebase replace the need for mongodb and parts of express or does it work in tandem with them?
If they don't work together why should I use one over the other?
MEAN stands for Mongo, Express, Angular, & Node.
If you use Firebase, you would basically be replacing the MongoDB part of the MEAN stack with Firebase. You would still rely on Node / Express to be your server framework, and Angular to be your client framework. Firebase would then serve as your data source as opposed to MongoDB.
The initial configuration would be different. So if you started with some sort of generator ( such as Yeoman or a MEAN boilerplate ), you would probably need to go in and remove any references to MongoDB & Mongoose.
To answer the question, "Why use one over the other", it is really up to you. They are both good solutions.
Firebase seems to be better for real-time data, and in my experience is easier / faster to prototype with than Mongo. If you get into some heavy usage with Firebase, you will have to start paying for it.
MongoDB may have more documentation when it comes to using it with the MEAN stack.
I am working on an HTML5 application. This app must store data (lots of JSON & Base64 pictures) until the user synchronises it with our server. I must keep data stored on the device for a month after a sync.
I will use Phonegap for building the app. I know there is a limit of 5MB, so I'll certainly have to store my data in a different way. What are the best solutions? What would you recommend me?
Edit:
I forgot to say, but I will have physically all the devices used by my company for installing the application, so maybe there is a way to overpass the restriction by tricking the Android pad?
That stands for localStorage and the built in SQLite database. I would suggest you taking a look at the File API, which would allow you to store files in the device.
There's a neat SQLite plugin here I'm using in an iOS/Android Phonegap application. I've tested it and found it's methods to work well on both platforms.
As for syncing JSON data and Base64 images, I'm doing this same thing with a SQLite DB managed through this plugin. I only have a couple hundred smaller images I'm working with but I've found the SQLite DB to be pretty reliable for this purpose.
Thanks to the authors of that plugin.
I'm building a webapp where one can develop documents within the web browser (e.g., something like Zoho's document tool, or Google Docs). In my case, I have a set of arrays that store different paragraphs and other pieces of information, along with parallel arrays that store metadata on the paragraphs themselves.
The entire webapp is written in jQuery and associated libraries / plugins.
Is there an elegant way for me to save this as a file on the server itself? So far, I've been recommended using a hidden form to POST the arrays to the server and store them in a NoSQL database of some sort... This feels a bit painful to me and I'm wondering if (1) there is a more elegant approach, or (2) there is a library / framework that automates some of the sending / POSTing / saving.
Thank you!
You would need to create services that live on the server itself. These services would be methods such as (just as a simple example)
SaveDocument(User, Document)
GetDocument(User, Document)
you would need to configure your web app to call these services and pass in the required parameters. Now as for how to do this, you could write the services in any number of languages (Java using JavaEE, C# using WCF to name a few, but you can also do this in python/ruby/etc) and then generate WSDL interfaces to the services that any number of other languages could call.
There are lots of resources available on the web that cover this, so pick a language you want to learn, or are already proficient in and google around on how to develop web services in that language.
Good luck!
I am a newbie programmer and i dont yet have any idea of the WEB. I wish to start learning a technology that will allow me to build websites( database driven) i dont know which one to choose. I know some actionscript3 and flash.
Is it possible to create a database driven website using these alone? Or do i need to learn any other technology? If i do then what should i learn? I know j2se for the desktop and oracle SQL/MySQL
please show me a path. Also wanted to know if there is any technology like Wordpress for J2EE/flash
OK so i finally got the feeling that i need to learn PHP anyway along with css and javascript. So it is fine. Also another query. Which CMS should i consider? Wordpress or Joomla?
You can develop a database driven website using Flash, but only in the same sense that you can develop a database driven website using AJAX. That is, you can build the front-end using Flash/ActionScript but the back-end is built using other technologies. Just like working with JavaScript to develop a front-end, from ActionScript you would be communicating with Java or PHP or Python or something on the server using RESTful calls and then actually working with the database in the server-side scripts.
Honestly = this question is too broad and generic, and answers are easily found with some google searches.
That being said = of course you can build a data driven flash site. The one caveat here is that flash itself is fundamentally client-side technology, so we must rely on other remote tech to do the heavy data lifting. The options are profuse.
For example, a developer might create a front facing presentation in Flex, which is the streamlined, data-centric extension of pure flash. His database interactions are written in php, and these are constantly called upon to deliver content to the user.
So - what technologies to use? Whatever you know. And if you don't know, then learn the ones that are closest to what you know.
Finally, although I am a die-hard fan of flash, this type of project (you didn't specify what you had in mind) could be done with many different technologies. So - maybe flash is the right answer, but maybe javascript (ajax) could manage the same thing and do it without the need of plugins.
Yes you can develop database driven site in flash/action script but you still need and back-end technology i recommend you to check WebORB you can develop the back-end using Java, PHP, or .NET In addition you can use Flash Remoting technology Flash/Flex to communicate with a back-end
Flash can't be directly connected to database. You must use another technique which would be "mediator". I have developed Flash game with MySql database and PHP and I recommend you to use this combination. Here is visually presented this kind of communication: http://www.youtube.com/watch?v=gRi-oxjFfCU
yes, it is possible to crate database driven website with flash and action-script. You would get an XML file when you do action script in flash, so you can store nodes of that XML file into database(mysql). You can then create an Admin interface to manage your database contents, that would indirectly change your xml nodes. So basically you can edit the xml file and store it in the database.
I am interested in knowing if there are any server-side web application frameworks which integrate nicely with CouchDB? Does anyone have any experience in doing this? It seems like a dynamic language would be well-suited for playing with the JSON, but I am more interested in hearing about how it would fit in with the framework and the application's design.
Two frameworks that I would suggest for CouchDB are Ruby on Rails and Django. Both have a small file you can include that allows for easy interaction with CouchDB. For Ruby/Rails, this gives you the ability to write code that looks like this (code snippets yanked from here):
# Create the database
server = Couch::Server.new("localhost", "5984")
server.put("/foo/", "")
# Insert a new document into the database
doc = <<-JSON
{"type":"comment","body":"First Post!"}
JSON
server.put("/foo/document_id", doc)
# Get the document back later
res = server.get("/foo/document_id")
json = res.body
puts json
Python/Django lets you do the same with a relatively minimal amount of work (see here). Both of these aren't at the web framework level but they require a minimal amount of work to set up and are pretty easy to get going in Rails and Django. The Django approach still requires some packages to be installed so if you just can't do that for some reason the Rails approach is the way to go.
Another good how-to on Python on Django can be found here (also lifted from the CouchDB FAQ).
The only web framework that dedicates itself to CouchDB is currently CouchDBKit for Python.
Check out the official wiki page that lists how to get started in your language:
http://wiki.apache.org/couchdb/Basics
Pick the language and framework that suits you best and then use one of the light CouchDB libraries with it.
It seems that things are move quite quickly at the moment for CouchDB. I'm sure there will be more frameworks out there soon with CouchDB support. I'm currently looking into building one for PHP.
I have had good success with jcouchdb for Java and CouchApp for JavaScript and CouchDBKit with Python. All of these are actively developed, open source and well designed and easy to enhance if they are missing something you really need. I have submitted patches and feature enhancements for jcouchdb and couchapp both.
Actually, you don't really need such a framework. Instead, you can just write the whole web application in CouchDB. It allows you to generate HTML files, or any other XML derived format, and you can even use HTML-templates. I consider this a good choice, because JavaScript is a rich and flexible language. On the other hand you don't have the overkill of a connection between the database and your web application.
For more details, check out: http://books.couchdb.org/relax/design-documents/shows
There's also a related question: Using CouchDB to serve HTML
Depending on what you want to build CouchApp may be something to look at: It's specially designed for writing apps with CouchDB:
https://github.com/jchris/couchapp/wiki/manual