meteor with lots of database changes - meteor

I'm getting stock quotes which happen a few times a second. I'm using meteor to display those quotes. I don't think meteor can keep up with the database. What's the best way to keep meteor speedy?
Should I set my query to be non-reactive then somehow manually call when meteor should re-render the templates?

If you are updating your db directly (outside of meteor), than meteor will take 10 seconds to reload and recompute the data changes from the database.
If you are updating your db through a DDP connection, than those changes should reflect to your meteor UI almost instantaneously, certainly keeping up with a few updates per second.
Apart from this, your publish function should not expose all fields of a document in bulk. Instead, you should publish just what is necessary to populate your UI.

Related

Ionic update local database without losing data

It's probably a simple and common thing but I just can't find any help to do this in Ionic 5 app.
I have an app with local SQLite db. During the development when I update the table in the local db, I need to delete app/clean storage on the device for the update to be available. Is there a way to apply new changes on the existing db without losing data (without creating the whole db)?
same once app is released, with new updates, how do I make sure that new db changes are applied without re-creating the database?
A simple way I can think of is to put new changes in dbService constructor and check every time and apply change if need to. But this doesn't feel right to me.
Thanks

Execute Flyway calback and report it inhistory table

I use flyway 8.5.0 and I want that my beforeMigrate or my afterMigrate sql is reported in the history table. Is this feaseable? or is there any config to setup this?
Then an other question: my repetable only runs when they change (checksum) but for my understanding the repetible sql should run every time. not so?
The beforeMigrate and afterMigrate SQL wont appear in your history table. If you look at the tutorial example for callbacks you can see that beforeMigrate can be called before the schema history table is created which would cause issues if it was trying to add itself to it. Additionally, I'm assuming these will be mostly static executions and would not really be part of the version history.
https://flywaydb.org/documentation/tutorials/callbacks
For repeatable, no they are only applied when the checksum has changed.
Repeatable migrations are very useful for managing database objects whose definition can then simply be maintained in a single file in version control. Instead of being run just once, they are (re-)applied every time their checksum changes.
https://flywaydb.org/documentation/tutorials/repeatable

Populate SQLite only once upon installation of UWP app

I am developing UWP application using vs studio 2017 version 15.9.6.
I want to use Windows local SQLite database. I want to run an SQL script named mySql.txt when the user first time install the application. I dont want to run it every time when the user run the app as it contain insert statement, which will cause duplicate rows insertion. So I want to run that script only once, preferably in the installation time.
How can I do that? I am very new to UWP and .NET. Please guide me step-by-step if possible.
You can make sure the initialization/seeding is done only once for the app. For that you may utilize ApplicationDate.Current.LocalSettings.
These allow you to write simple data for your application which are bound to your app. Once the user uninstalls the app, these data will be removed as well. This fits your scenario exactly.
Suppose your database initialization code is in the method InitializeDb(). You could use the following to make sure the initialization is done only once:
if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("DbInitialized"))
{
InitializeDb();
ApplicationData.Current.LocalSettings.Values["DbInitialized"] = true;
}
This code first checks if we have initialized the db previously and if not, performs the initialization and stores a flag into app settings to make sure the next time the initialization is skipped.
You can run this code during app initialization, for example in OnLaunched method, or on when the database service is first required.
This is of course the simplest implementation, so you can (and should) add some exception handling, so that if the initialization fails, it can be retried and so on. Also you may want to handle app updates and DB updates - in which case you can use ApplicationData.Current.Version which allows you to track the version of application data and can be used to keep track of DB version as well so you can perform appropriate migrations between versions.
Finally, for even better user convenience, there is also a way to perform the app update steps during updates. See this article for more info.

Meteor dynamic update

I understand that meteor automatically updates the view based on the underlying model, ie if there is a model change, then all the clients' views will be updated as well.
What happens if a 3rd party app updates the database directly. Will meteor pick up that model change and display it to the view, or is it only model changes done through the meteor stack that will be updated?
You mean if you have some other app updating the same MongoDB? Meteor will notice and show this change to the user!
If I for example update my MongoDB directly from the MongoHQ's console it's reflected in my app instantly.
Meteor polls MongoDB each ~10 seconds or so. You need to use ddp-client to update MongoDB through Meteor for your changes to affect the model immediately:
Using node ddp-client to insert into a meteor collection from Node

How to perform specific operations during installating or updating a TideSDK app?

I went thru the docs but couldn't find how can I perform specific operations when app is being installed or when app is being updated.
What I want to do is, create table when app is being installed and if in future, db schema changes, I want to perform those operations when app is being updated.
According to me .. the best place to do these changes are in the code. so whenever the application starts up first time after getting updated.. you do all the db schema changes.
This makes sure that your application is fully updated before you touch any database and secondly u do not have to write any special logic separately while installing / updating the application.

Resources