Data History with sails js and mongodb - javascript

In the past I have been using aown node/express/mongo application. But in future projects I want to build on top of a framework such as sailsjs. On my projects I have used mongoose with the addon mongoose-version, which covers all data versioning (or data history) if you have it configured once.
Now my question is, if there is a comparable plugin as well for sails which tracks all changes done on my mongodb?
Thank you in advance!

Related

How to connect React Native and PostgreSQL?

Hey guys I have a question regarding React Native and PostgreSQL.
I've build a rn App where you can save data like hours, project and a comment and another screen where you can load it. It is a project for my workplace where we have an intern timemanagement system. Our database is a PostgreSQL database.
My question is how do I connect to our database ?
- I have a test DB running locally on my pc, I would like to connect to it first.
I did some research and found that I need to use fetch request.
Then I found out that there are two approaches (kinda):
1.node-postgres npm package (my Q: Do I need to know how to write in NodeJS?)
2.postgraphile GraphQL (my Q: Is it easier to do it with GraphQL? Do I need to be a GraphQL expert?)
I really appreciate any response or tipps you can give me.
Sincerly Faded.
The best way is to expose your data with an API, with nodejs and node-postgres for example.

Sails.js 1.0: How to connect and use legacy MySQL database without Waterline?

We have a legacy app that has a MySQL database. It's backend is currently written in PHP.
We are now revamping the backend and building a backend in node.js. The tech team has decided to use sails.js as their framework for building this backend.
Sails.js by default uses Waterline (ORM).
What we want is to be able to connect to our legacy MySQL database and drop orm support in our sails app.
When initializing a new sails app, I passed a without option to opt out of orm in my app.
Now, I am confused as to where (and how) should I connect to the legacy MySQL database in a single place and make that connection available to all the controllers/action files that we will have.
Do I still have to use sails-mysql, or should I use any other adapter that helps me connect to the database? Where should this code live? Inside a helper method ?
Any help would be appreciated!
If you created the application with --without orm then you basically disabled any ORM/model/database functionality that Waterline/Sails offer. That means, you cannot use the models concept as documented in Sails.
You can always use other methods, just do it like in any other node.js project. Require the module, and follow their documentation. Check http://docs.sequelizejs.com/ for one of the many options available.
And about using sails-mysql, that is just an "adapter" for Watermark that tells your connection that you want to use 'mysql'. But that is only available when you do have ORM configured in your application.
If I were to develop the application without ORM, I would create "services", called then in controllers. That is, build your business logic in /api/services (create the folder if it doesn't exist) and then develop your solution there. Finally call them from your controllers. You can check my other answer here for an example

ReactJS front-end with NodeJS backend: Rendering

I'm currently making an application using ReactJS for the front-end and NodeJS for the backend, however, I'm confused regarding how to connect those two.
I read about both, server-side rendering and client-side rendering.
I followed this tutorial (https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/ ) as to how to connect my ReactJS app, which I created using creat-react-app and my node backend, however, I read that the solution of adding "proxy": "http://localhost:8000" (or whatever port node runs on) to the package.json file is only suitable for development.
Anyway, what I would like to know is: What is the best way of connecting ReactJS and Node.js if the user should be able to enter,delete or update data, which is saved to a database?
You should check out Nextjs. It is based on React and NodeJS.
I believe this is exactly what you are looking for. It is an easy-to-use framework that handles all the difficult stuff when it comes to server rendering while keeping the frontend async and dynamic. Besides that. When you get better using it, you can do in dept configuration to optimize to you need. Hope that helps.
Try out one of the examples on the git repository.

MySQL bundled within an NPM app

The idea is to bundle the MySQL database within the npm app. The reason behind this is because the app is intended to run as a stand-alone desktop application built using Electron and, of course, many other modules.
So far, all of my searches for a MySQL database module only leads to the drivers. All other tutorials talk about the typical web app set up wherein the MySQL db is installed in the server. A comment from another post discussed how to set up MySQL db in server and just mentioned that if it's a desktop app, it's a whole other issue. I want to know if there is a way to do this or if it isn't possible at all.
After further research (and a lot of compromise in the initial design), I decided to use Lovefield by Google. It is the closest to what I have been looking for since 1. it is embedded in the browser and 2. structured query is how you get data. Still hoping there would be a solution to an embedded MySQL database in an Electron app.
Sometime in the past, I have managed to embed a full Drupal CMS installation inside of node-webkit (https://nwjs.io/). It was configured to proxy all the known PHP files to the embedded PHP installation. Then we have simply imported the sql dump file into sqlite and the entire thing worked out nicely. You might want to give that a try.
As #jd-hernandes pointed out, sqlite could be the answer you are looking for.

Integrating an operational transformation library with Meteor

When building apps with Meteor, its capabilities have really amazed me. However, to be able to drop in Etherpad-style collaborative editing bits into my app would really be a holy grail.
While looking up how to do this, I found some projects that seem to use OT libraries in meteor.
Projects using ot.js:
https://github.com/TeamCocoDojo/cocodojo (Demo at http://cocodojo.meteor.com)
Projects using ShareJS:
https://github.com/mad-eye/meteor-sharejs (Demo at http://madeye.io/)
I can't seem to tell how these projects integrate with Meteor. Are they actually using Meteor Collections? Do they just use the Node server that is hosting Meteor and do the OT as a separate component, not using Meteor at all? Is there a different OT library that integrates better with Meteor?
If anyone is familiar with these projects or has implemented OT as part of a Meteor app, please share your thoughts on the best way to approach this.
(This isn't a duplicate of Operational Transformation in Meteor.js? as that question is almost a year old and Meteor has moved a long way since then.)
I've started the process of integrating ShareJS with Meteor via a smart package:
https://github.com/mizzao/meteor-sharejs
Please try it out in your Meteor app, and submit new features!
Demo here:
http://documents.meteor.com

Categories