How does BreezeJS caches or stores data locally? Does it use window.localStorage for caching/storing the retrieved data? Or is there any other approach for BreezeJS to cache/store locally?
If it uses window.localStorage, what would be the key name would be?
The reason I want answers to these questions is: We will be creating lot of localStorage data for our application and we don't want to erase or overwrite BreezeJS localStorage data.
Breeze caches data in memory inside of instances of the Breeze.EntityManager. It you want to persist this data locally then Breeze provides methods such as EntityManager.exportEntities and EntityManager.importEntities to serialize and deserialize the contents of the EntityManager cache to and from a string. You can store or retrieve this string from any client side persistent data store, the most obvious being localStorage. There are examples of this in the DocCode sample in the Breeze zip.
In your case each export of the Breeze.EntityManager can be stored in local storage with a separate key, so there will be no issue of overwriting data unless you explicitly want to.
Hope this helps.
Related
I'd like to use Realm as a persistence model to represent my CloudKit public database. Is this possible?
Specifically, I would like to use CloudKit to take a Realm data model and store it in my CloudKit public database.
This would overcome my current issue of having to fetch data from CloudKit every time the app is loaded in to memory. Without a local data model, when there is no internet connection, no data is fetched because there is no persistence.
If the app is removed from memory, any data held in the app that was fetched from CloudKit is also removed from memory.
It is possible, you just will have to write the code to convert your model objects to/from CKRecords that can be sent to CloudKit.
If you were trying to use the private database, I would suggest using this library, which is compatible with both Realm and Core Data (disclaimer, I'm the author): https://github.com/mentrena/SyncKit
Another solution, for Core Data, is https://github.com/nofelmahmood/Seam
However, the public database doesn't allow to query for changes, so you would have to roll out your own implementation to keep a cache of some record query, rather than a fully synchronized local cache of your whole model.
In my opinion, if you want to use CloudKit, you should use Core Data as the persistent store. It works very well together.
If you prefer modern solutions, try Realm Mobile Platform https://realm.io/products/realm-mobile-platform/
Also, you can try to write some custom backend with Vapor and use Realm as the persistent store.
I have live application on the app store. It uses SQLite data storage and ugly methods that save and get data form it. I have replaced the data model with core data. So right now I have one table that contains favorites list. I suppose user will lose their favorites data, and the second problem will be that previous SQLite data base will be in the app.
What's the best way to migrate that data to new data base. So code was ugly, I have started to write new project. It means that there will not be any SQLite data base as before with the same name, just new Core Data db. How usually we need to solve this problem.
I think I can add a method in app delegate that will check if data base with name in the application I will try to retrieve all data from that storage and convert it to the Core Data entities. Then when data will be converted with success, I will drop that database. When I will if all my active users will have this update. I will remove this feature from app delegate because all will up to date. Does it make sense?
Your approach is correct. In the new app version, check if there is an up-do-date Core Data persistent store, if not, read the old data, copy it to Core Data, delete the old sqlite file.
You can leave that code in there for a long time - it just won't run if there already is a valid Core Data installation.
I am trying to use multiple (two) persistent stores with Core Data for the first time.
It seems quite simple to add a store; but once this is done, how do I specify that a request to write (or read) some information to (or from) an entity has to be performed on one store or the other?
Some sample code would be welcome, but I can’t find anything on the net.
Fetches always cover all of the persistent stores managed by the coordinator.
When adding data, you can do either of the following:
Use configurations in your data model and when adding persistent stores. Configurations define named subsets of your model that contain some but not all entities. If an entity only exists in a configuration that's only used with one persistent store file, then new instances will automatically go to that store.
If the above doesn't work for your app, you'll need to call assignObject:toPersistentStore: to tell the managed object context which store to use.
Is it using core data?
Is the data encrypted in any way? Is there a way a user could maliciously modify it easily?
I have been trying to look for this answer since LDB was announced for iOS, and have not found any information regarding this other than 'it is just like our android implementation'. If this information is stored in plaintext I cannot store sensitive information in it, which is why I would like to know.
I've just created an app that uses the local database, and here's what I've found.
Inside <app sandbox directory>/Library/Private Documents/Parse there is a file called ParseOfflineStore. This is a sqlite database. There are 2 relevant tables inside (ParseObjects and Dependencies), and pinned objects are stored inside ParseObjects.
To answer your questions:
1) No, it does not use CoreData, but it is sqlite (the same db backing store as CoreData).
2) No, it is not encrypted. It's in the clear, stored in the ParseObjects table, in the json column as cleartext json.
It would be relatively trivial for anyone who can hook up iExplorer to the app to download, change, and upload the local database. However, if you have a user who can do that, it's likely they could proxy your app with Charles anyway ;-)
In some requests, external data has to be fetched from Soap service. Obviously I don't want to get that data at each call for the same user.
What is the best practice to store temporary data from one request to the other? The data could take up to 10 meg.
If you really need to persist that amount of data between web requests and the data is specific to the user I would suggest serialising it and storing it a temporary table in a database with a key to the users session. If you are using Sql server session then you can do this via the Session object otherwise you will need to write a custom implementation of this.
If the data is not unique to the user but could be shared then you could store and retrieve it from the appication cache.
A concrete answer depends on more information about the application and about the data structure. You could consider to put the data into a temporary file. If memory is not concern and you don't have lot of parallel users you could use session state.
Maybe storing it in file on disc will be enough but then you must create own implementation of file manager or something like this.
10Mb for session is too big but sending it to the database is waste of resources. Saving to file will be lightest and fastest method for temporary data.