feathers.js - saving one record to multiple databases - mysql and elastic search - feathersjs

I have built an app with Feathers.js and I'm trying to find the way, how can I save any record to the multiple databases? I would like to save a "message" for example to the mysql and also to the elastic search.
I would like to use elastic search for "full text" search, but I would also like to have all data saved in some relational database.
I've created a service using:
feathers generate service
but I can select only one specific database there.
Any help will be really appreciated.

Fast way to me is to create another feathers app (microservice) for elasticsearch and post the data to elasticsearch too.
If you are using socket in the frontend app you can define 2 sockets (1 for each micro service).
When you post new data to feathers app 1 (mysql) you can :
on response of the data created post the same data to feathers app 2 (elasticsearch)
on error abort and correct
or
add a service('your_post_service').on('created', ... and then post data to feathers app 2 (elasticearch)

Related

how make post from mysql to external client

how can I send json data through a post request to an external client from mysql commands?
POST(select * from clientes)
I need to develop an application and python that listens to a pot from mysql, every time a new row is inserted from a database table, that is, when a trigger is performed

React: Store <Form> data from to MySQL

I have created a register page in reactjs, where I am taking firstName, lastName, password, email from a user.
In the backend, I have created the application using SpringBoot to handle the request from frontend.
Now, I am able to store (temporarily) the register form data in http://localhost:8080/forms .
When the user enters the data in register form at the front end, the data is stored temporarily in the spring boot application in the url mentioned in the axios.
So, when I enter this url (in the browser), am able to see the list of registered users with their credentials in JSON format like this :
[{"firstName":"Bhavya", "lastName":"Gupta", "email":"abcd#a", "password":"zaqxsw","id":100}]
But this data is temporarily stored, so when I restart the server the data is no longer there.
submitBook= event =>{
event.preventDefault();
const book = {
firstName: this.state.firstName,
lastName: this.state.lastName,
password: this.state.password,
email: this.state.email
};
axios.post("http://localhost:8080/forms",book).then(response => {
if(response.data!=null){
this.setState({"show":true});
setTimeout(() => this.setState({"show":false}),3000);
} else {
this.setState({"show":false});
}
});
this.setState(this.initialState);
}
The complete code is available here
I want to store the register form data from front-end (client-side) into a MySQL database, so that I can perform login authentication on the data stored.
I have created MySQL database with 4 columns - firstName, lastName, email, password. I searched on the internet and read several answers in SO Sending data to database in React, referred several blogs and articles, but I am not able to understand how to achieve this.
Can anyone please help me out in solving this issue?
In a typical/modern web application, you have well defined roles/purposes for each part of the system. From your question, it appears that you intend for the roles to be interchanged and that might the source of your troubles here.
Let;s look closely at your set-up:
Client-side/Front-end (JavaScript/React)
This is simply an enabler for a user to interact with your actual application. In your set-up, this should render the form and capture registration data.
Server-side/Back-end (Java/SpringBoot)
This is your application layer where most processing happens (business logic).
In your set-up, this is where your MVC happens. And essentially, after any required validation, this layer then communicates with the Database.
Database-layer (SQL or NoSQL)
This is the layer that you utilize to store and persist data within your app. In your set-up, you are using MySQL to handle your data.
Already your backend is already exposing endpoints which you are consuming at the front-end via axios. Therefore the direct answer to your question lies in getting SpringBoot to work with your MySQL in order to persist your data.
Here is an official tutorial on how to access data with MySQL from the spring team.
For Posting Form data from ReactJS to MySQL database via Spring Boot Application, I have written blogs, that gives a detailed explanation and a step by step method to connect front end part with backend .
Refer to these blogs :
Prerequisites to POST form data from ReactJS to an API endpoint : Part 1
Initial Setup for creating a basic React App: Part 2
Posting Form data from ReactJS to MySQL database via Spring Boot Application: Part 3

Flutter: rendering an UI from JSON and store / map data dynamic

I want to render a UI from a jSON string that has multiple layers.
The user should be able to enter data, which will then be stored and shared, without the overhead of the jSON Render Structure.
However, the assignment of the data must be possible.
The app renders a template from a multidimensional json string that can capture metrics (user inputs). The measured data are entered via text fields by the user.
There are different windows in the app, which are rendered from different json UI-render-files.
The stored algorithms in the windows at the Frontend differ.
The following should be possible:
All windows are created with different jSON strings (works with build_value now).
The user's input is saved. (Currently only works by saving the render json string with the data under a different name (with Package: Shared Preferences)).
The data entered by the user is copied from one window to the other window. (Data Binding / Data Mapping)
The data entered by the user will be sent to a backend.
I only have the idea to use id's in the render json, which allow a mapping.
Are there better solutions?
Saving the entered data is possible by saving the whole jSON - String with an other name.
The goal is to map the data.
It should also be possible for the user to insert another object for the measurement data acquisition at the client / device. The entered data must also be saved.
This sounds like a REST API. Then you would use a frontend framework like angular or react to take user input.
I could build this with a .net core web api with sql db as the backend. this would be a web service (REST API solution) on the backend of your solution.
Next I would integrate Swagger with dependency injection and add authentication.
now its time to create the front end that will use your tested Web Service.
you would have 1 side of your SPA POST new JSON to the Web service in a form.
you would have the other side GET the new record as a new tab with pagination or in a table with pagination.
This would be a good PoC for your idea and will let you learn the parts of the solutions architecture in your language of choice. the "design" would be the same no matter what language your choice.
backend web service can be done in a flask and with a MySQL DB. or with any other combo you have skills with.
the Frontend could be done in knockout.js, making it a little easier to learn than angular or react.
Please create new questions when you choose your software design. I would love to give answers for each:)
I would love to level up with you! ;)

Adding a mysql user store with custom schema to WSO2 Identity Server

Currently, trying to use WSO2 Identity Server to authenticate users from a mysql user store that I created with my own schema. However, whenever I add this user store as a secondary one in WSO2, the users do not appear on the management console.
And when I attempt to authenticate a user from that store I get the error message:
[2019-05-24 10:01:15,951] ERROR{org.wso2.carbon.identity.auth.service.handler.impl.BasicAuthenticationHandler}
- Error occurred while trying to authenticate,
Error when handling event : PRE_AUTHENTICATION
The user stores of the WSO2 servers need to have the specific schema (the schema script located in the dbscripts folder). You need to import users using this from your existing schema or scim2 endpoints to programmably import users
I you cannot migrate user store to wso2 schema as senthalan explained then you have two options to plug custom schema.
Change SQL queries from Advanced option of secondary user store configuration
Writing custom user store manager by extending necessary functions like doAuthenticate, doAddUser [1]
Error when handling event : PRE_AUTHENTICATION basically coming from below listener
org.wso2.carbon.identity.governance.listener.IdentityMgtEventListener in identity.xml while handling pre authenticate event. You can even disable it.
[1]https://github.com/GayanM/custom-user-store

grails to build Web interface using REST API

I am fairly new to Grails, and I have a few questions on how to proceed.
I have a REST API which I will use to retrieve the data , for exemple :
http://localhost/api/data/list
Which gives this result :
{"data":[{"col1":"blabla","col2":0},{"col1":"moreblabla","col2":1}]}
I want to use Grails to build an interface for those data (show, edit, add, delete)
Should I create a domain called Data ?
How do I tell Grails to to use the REST API and not a database ?
I am really clueless so I hope you can light the way ;)
Thank you.
Grails currently doesn't have a GORM plugin for using a REST endpoint as a persistence store. That is planned functionality, but is not slated to land until later this year (2012 - Q4).
That being said, you can write a service that will allow you to do basic CRUD operations on an object and get/persist to and from your REST endpoint. The place to start with that is the HttpBuilder, and perhaps the REST client plugin.