Reading data from a dynamodb table in real time - javascript

I am currently building a serverless solution and run into a corner, basically i have a table and i want to be able to read data from that table in real-time as new entities are saved in the table from my client(front end react application). I have come across multiple solutions during research and i still am not sure which is best for my use case. I saw dynamodb streams allows you to get data as its being placed in the table, but i am still unsure as to how i can plug this in to my frontend to read the data, i also saw kinesis streams, and web socket api, the web socket api. im confused as to which to use.
My use case:
i have an orders table, where users place orders and i want when a user places an order to my order table, my front end(react) should be able to pick up that data and display it.
Can any aws devs direct me to a service that will be best to implement this usecase?

you can use Appsync Subscription, whenever a new order in your dynamoDb table Subscription will show it.

Related

Laravel livewire - any way to get live data from database?

I have a project for food ordering and deliverying. Basically this is a concept of project:
User order a food in some restaurant
That order of that restaurant is showing specifically to the manager of that restaurant
Manager is getting SMS notification about new order
He needs to refresh his dashboard to see new order
The point is in the last step Manager needs to refresh his dashboard to see new order.
I'm using livewire and Laravel 7 framework, is there any way for the manager to get new orders in realtime?
I know for livewire polling but I don't want to use that because it can cause server problems in large quantities of using it. Is there any other way? Something like mount() function or emit ?
I've never used this feature but it seems you need broadcasting
In many modern web applications, WebSockets are used to implement realtime, live-updating user interfaces. When some data is updated on the server, a message is typically sent over a WebSocket connection to be handled by the client. WebSockets provide a more efficient alternative to continually polling your application's server for data changes that should be reflected in your UI.

Best database for daily data?

I'm currently working on a project where I'll be tracking daily data for around 30 fictive companies. Every company has a name, rank and balance. I want to track the rank and balance by saving the data everyday.
Now my question is how to store this data, should I use csv files, Json files, or a database? And if thats the case, wat database should I use as a beginner?
My project is build in javascript with nodejs and discordjs.
You can add timestamps in json, you should take a look at it!
Since you're using discordjs, If I am not wrong you would be fetching details using the discord api. So for data storage you can go for firebase either Realtime database or firestore database. It's super easy to implement and easily scalable and there are too lot of additional feature you will get along. This way your database will be easily fetchable from anywhere also.
Also you can anytime download your database into csv. Here is the the official firebase node-js sdk documentation.

How to have one to one chat using firebase in AngularJS

I am trying to have a one to one chat feature using firebase. Right now, my structure of messages makes sense in the fb database but I am not able to implement one to one chat feature using firebase's api in angular. I am able to spam a chat room where all the users can see everyone's messages but i would like to have a one to one chat feature in my application. My structure is good in the firebase database and i just need to manipulate my javascript code to make it work. My code is as follows.
function chatController($scope,$firebaseArray) {
var ref1=firebase.database().ref().child('users/59c1c11cec/chats/-KuRshPYbO_d9B');
$scope.chats=$firebaseArray(ref1);
var ref=firebase.database().ref().child('chats/-KuRshPYbO_d9B/messages');
$scope.messages=$firebaseArray(ref);
$scope.send=function(){
$scope.messages.$add({
message:$scope.messageText,
// date:Date.now()
})
}
}
I am able to create a one to one chat between two users by hard coding their user ids, but I was wondering if firebase's api is able to do this dynamically. If yes, how would I do it? For reference, 59c1c11cec is the current logged in user id, -KuRshPYbO_d9B is the other person's id who the current person is starting a conversation with which I don't have any access to in my own database but only in firebase's database. And using that users id I retrieve the messages between the two users. How will I be able to achieve this? I just need to replace the hard coded values with the values I talked about.Thanks a lot in advance!

Angular2- few questions related to data saving in a static web page

Im coding a static page app using Angular, which shows various Instagram and Twitter posts of the company, and shows the details of the members. I have few questions regarding this, and would like any help.
Firstly, I have about 100+ contacts to display on the first page. Should I create a Json by myself and retrieve it from the service, or should I create a backend and save it there ? I do not have any backend as of now.
Other thing, I was able to retrieve Instagram Json with media content using their API, the doubt im facing is, once I have the call done, will the Json change automatically when the user adds/edits their posts? Or will the Json be the same as I first called it with? Any help is appreciated. Thanks.
For your case, as you have fewer data using Firebase is the best approach. If you write a backend and maintaining it would cost you more. You can use Firebase service URL to retire those records. In future, if you want to add more data it would be easy.My suggestion is Firebase.
Should I create a Json by myself and retrieve it from the service, or should I create a backend and save it there ?
Are you revealing credentials or other sensitive information in the client? That would be one reason to have a backend apart from Instagram or Twitter. Do you envision exhausting API rate limits of Instagram or Twitter APIs? That would be another reason; you could cache results in your backend to reduce external API traffic. Do you need to process (reduce? translate?) the data before it gets to the client, or are you satisfied with performing any processing on the client (e.g. is it fast enough)?
TL;DR: It depends a lot on your particular requirements.
If you do want a backend, the recommendation in the answer from #praneeth-reddy to use Firebase is excellent. If you only need processing/transformation but no caching or separate storage, then AWS Lambda may also be worth considering. If you need more control (build vs. buy), you could write your own backend.
...will the Json change automatically when the user adds/edits their posts? Or will the Json be the same as I first called it with?
Angular can help you update content automatically if the client side data (think browser JavaScript memory) changes via its automatic change detection functionality, but you would have to provide your own logic (e.g. in Angular services perhaps leveraging RxJS) to update the client side data based on data from the APIs. You could poll to update periodically, or for better performance listen for changes using an asynchronous event/push mechanism such as websockets or streams.

Best way to get and store data (optimized) to mobile app (Ionic, Cordova/Phonegap)

I want to do an app with ionic framework and cordova for Android and iOs and I want to optimize at most the requests to the server.
I need to get data from php server (API) and store in the mobile phone, this data is related, so I think that a SQLite is the best option to store it in the device because of to show it is more fast to do a complex SQL than get a JSON stored in localstorage (for example) and search and link the data in the mobile. I'm right?
I need to do this and can do a Pull to refresh in the app and get only new data.
I've been watching some solutions but I don't know what is the best.
Parse/Firebase: This is difficult to administrate for non-specialists, for this I have a backend to enter and modify data with the relations easily. In addition this services return a JSON with more data that I need.
Persistence.js and Persistence.sync.js this works with mysql-server and sqlite-local but can I sync only one table or get only the new data? And I did't find a solution for php server.
CouchDB and PouchDB: I don't know if this can be sync only for a new records.
Receive data in JSON and store it in SQLite: I need to create functions to do this easier.
Any other solutions?
I'm very lost in this topic.
Thanks!!
CouchDB and PouchDB: I don't know if this can be sync only for a new records.
That’s the default. Plus they handle all the nasty sync details for you. Would highly recommend looking into this.

Categories