You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
8 months ago | |
|---|---|---|
| LeStorage | 8 months ago | |
| LeStorage.xcodeproj | 8 months ago | |
| LeStorageTests | 8 months ago | |
| .gitignore | 2 years ago | |
| README.md | 12 months ago | |
README.md
LeStorage
Rules
- To store data in the json format inside files,
you first need to create some model class, for example
Car - You make
CarinheritModelObject, and implementStorable - To get the
StoredCollectionthat manages all your cars and stores them for you, you doStore.main.registerCollection()to retrieve a collection. LeStorage stores data as JSON files inside the storage directory.
Multi Store
You can store collections inside separate folders by creating other stores:
- Use StoreCenter.main.store(identifier: id, parameter: param) to create a new store. The directory will be named after the identifier under the storage directory. The parameter is used to retrieve data from server as the GET requests will add the parameter as an argument in the URL, like https://www.myurl.net/api/cars/?param=id
Sync
- When registering your collection, you can choose to have it synchronized. To do that:
- Call
StoreCenter.main.configureURLs - Pass
synchronized: truewhen registering the collection
- Call
- For each of your
ModelObject, make sure thatresourceName()returns the resource path of the endpoint, for example "cars" - Synchronization is expected to be done with a rest_framework API on a django server
- On Django, when using cascading delete foreign, you'll want to avoid sending useless delete API calls to django, so override the
deleteDependenciesfunction of your ModelObject and calldeleteDependencieson the collection for the objects you also want to delete to reproduce the cascading effect