MySQL or JSON view base on Node.js app and API - mysql

I know this kind of question is ask in many different ways, and I know that's annoying for answering so much same question, but as I google it, search in Stackoverflow I can't really find a nice answer, the answer I'm asking is based on views like easy for answering API request (which is in JSON format) and in the view of I'm designing Node.js APP
So here is my case
I'm building my own Node.js application somehow like a CMS or blogging platform so imagine I need a place to store all my posts data where should I store in a MySQL database or External JSON file it's quite confusing I personally prefer JSON since it's nice looking (?) but it's quite hard to use fs.writefile and fs.readfilesync to update data in the external JSON, but I don't know how to make an API that will give the post data by MySQL database since the API is in the JSON format
If I have any misunderstood please tell me

if you want to store data in json then go form nosql database like mongodb. Postgresql latest versions also supports JSON data types.

Maybe what you need is ORM module, for example sequelize
It works with MySQL/Postgres, and offers you APIs like MongoDB.

Related

Can I use GraphQL for mongoDB or mySQL?

I have started learning GraphQL and found that GraphQL is an awesome query language.
However I wonder if I can use GraphQL for existing databases such as mongoDB or mySQL.
Also please explain about prisma.
Is prisma a cloud database or something?
Edit:
TL;DR:
GraphQL can be used with any database as long as the data satisfies the type-strict qualification. Prisma is a node.js/typescript ORM library and works great with GraphQL.
Looking back to this a bit old question, I noticed that the question was so dumb and a bit too wide. So I've decided to add some more thoughts as I'm now quite familiar with GraphQL and Prisma. Hope this could be a help for new developers who are starting to learn GraphQL and Prisma.
GraphQL is a query language that we can use to interact with the API.
Like the REST API, GraphQL is another type of API format where we can use Queries to get data and Mutations to update data.
As the REST API doesn't depend on the database type, GraphQL can also be used with any database as long as the data can be formatted into type-strict models.
On the backend side tho, you need to implement the GraphQL interface that reads data from the database and sends as the Query response, and updates the database with the data from the Mutation.
Prisma on the other hand is a node.js/typescript ORM library - similar to mongoose or sequelize. The benefits of using Prisma is that it auto-generates the TS models and makes it much easier to interact with the database in typescript.
As GraphQL and Prisma are both strict in type usages, they match quite well. Also, Prisma provides an exclusive interface for GraphQL implementation, so you can easily write GraphQL interface with Prisma.
Please check out here for more information on the combination of GraphQL and Prisma: https://www.prisma.io/graphql
It was a long edit, but hope this helps.
As it was mentioned on previous post - yes, you can.
An example, if you backend application wrote on .NET stack - you may use, guess two, main libs that really tested and guys use it in real projects (google GraphQL.Net and second lib should be spelled almost the same)
But, both of these libs give you only processing of graphql queries and describe schemes ("accounts {id name}" means you should define resolver which returns data from db or another data source)
Most of guys use EF (EntityFramework) as a data-adapter between GraphQL and db. But, from my point of view it's useless, especially, if we are talking about get data from db and that may be thousands requests.
We implemented component that based on light-weight DB lib (to almost all popular dbs like MSSQL, Postgresql, MySQL or Elasticsearch), gives ability to configure GraphQL scheme very easy and provide main features like sort, pagination and complex filter.
Yes, you can use it with existing DB.
Prisma is an ORM layer build using GraphQL server, it abstracts away the database and let you interact with the database using GraphQL query. It currently supports MySQL, MongoDB, AWS RDS & PostgreSQL. It's not a database, but you can host it on the cloud.
Typically, you need another GraphQL server that inside it resolvers will call Prisma's GraphQL server. This GraphQL server is the one that is called by the client.

Get tweet JSON into SQL table with nodejs

I'm getting some tweets from the twitter API with nodejs and saving some of the data with mysql. Gradually as I require more and more data from each tweet, it's become obvious I should just save the whole tweet each time. I'm looking for the cleanest way to save a whole tweet straight from a JSON object to a new row in my db.
I was surprised there aren't more node modules or anything pre-written for creating the database table ready for tweets and mapping a tweet's JSON schema directly to it - can anyone help? At the moment I'm using the 'mysql' module for queries and thought about combining it with 'json-sql' for building the query, but it seems like this must be such a common thing that there should be an even simpler way.
Is anyone aware of another process? Thanks!
I eventually moved over to using MongoDB, it works really well with NodeJS and I'm really enjoying it.

how get table data and post data for Navistion Database in phoneGap

We are very struggled about getting and posting table data for Navistion Database.We need getting data for Navistion DB to our local(sqlLit) DataBase and posting data SqlLit Db to Navistion DB.In PHoneGap
We are goggled.But no luck.So Please give any documentation and link .Please help me.
PhoneGap/Cordova can work with other databases when you use middleware on your server to respond to it. So for example, your server (with the Navistion DB) could use PHP or ColdFusion to respond to Ajax requests from your app. It would handle taking the request, querying the db, and converting the response to JSON. There is no documentation link for this as it is too abstract of a question really.
Agree with Raymond - the question is too general to give any kind of recommendation. Maybe if you could elaborate it a bit - at least outline the task you need to solve, it would be easier to suggest something.
Anyway, I presume, you don't want to insert data into the Navision DB directly, but need an interface to Nav functionality. My first idea would be to look at Web services. Some documentation is available on msdn: Web services in Nav. You can expose Nav objects (Codeunits, Pages and Queries) through a web service and call it from PhoneGap.

Is it possible to write mysql queries in Angular.JS?

Im new to Angular.JS and just wondering if it is possible to write mysql queries in angularjs?
I would like this as I am trying to create a messaging system in which I query the database and get the information live to the webpage.
Any help is appreciated, hope the question is reasonable. Gab
That is not advisable (if possible at all) as it would defeat the purpose of Angular.
You should consume data by targeting a RESTful api/service exposed by the server. The service would handle the DB access for you and provide the data to Angular using a more portable format (e.g. JSON or XML)
Some of the basics of linking Angular and REST are described here
There are related questions on SO about exposing your particular DB flavor using REST here.
This can only be a starting point but it should give you some ideas. I will try to amend this with more info as I come across it.

How to use JSON to export data

Thank you in advance for all your support.
I wanted to inquire about using JSON. I understand that JSON is used as a means to take data from the db and display it on a HTML page (or perhaps even export the data to a csv file). What I am not understanding is do we use JSON to exports all kinds of data, even sensitive data such as SSN, Username, Password and etc...? I have done some research and what I am finding is that many articles mention not extract this kind of data but I do not understand why. My end objective is to build a system where I want to allow my clients to be able to export data from my system to theirs. I would like to also mention that I am building this using MongoDB. I'm not sure if this really matters or not, but thought I would mention it.
I am really looking for knowledge here about JSON and how to correctly use it. I don't need to know how to write JSON or something.
Thanks in advance again.
AJ
Actually, MongoDB uses BSON, not JSON. The MongoDB shell and some drivers abstracts it as JSON to make it more human-readable.
MongoDB has no build-in support for data encryption. That means when you have sensitive information, you should encrypt it before putting it into the database and decrypt it after you retrieve it.