{"id":15692651,"url":"https://github.com/karolzak/mobile-app-documentdb-offlinesync-sample","last_synced_at":"2025-05-08T02:44:38.619Z","repository":{"id":82133538,"uuid":"78621402","full_name":"karolzak/mobile-app-documentdb-offlinesync-sample","owner":"karolzak","description":"This is a proof of concept project where we tight up a DocumentDB instance with complex (nested) types with several SQLite mobile clients using Azure Mobile Apps with Offline Sync.","archived":false,"fork":false,"pushed_at":"2017-11-05T05:47:28.000Z","size":168,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T16:52:53.237Z","etag":null,"topics":["azure","azure-mobile-apps","csharp","csharp-code","documentdb","incremental-sync","json","mobile","mobile-app","mobile-development","mobile-first","nested-objects","offline-sync","sqlite","uwp","uwp-applications","uwp-dev","xamarin","xamarin-android","xamarin-ios"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karolzak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-11T09:04:11.000Z","updated_at":"2024-03-31T16:06:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"48cdccd1-9fcf-4d19-b2fa-c86fedb9c1c0","html_url":"https://github.com/karolzak/mobile-app-documentdb-offlinesync-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolzak%2Fmobile-app-documentdb-offlinesync-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolzak%2Fmobile-app-documentdb-offlinesync-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolzak%2Fmobile-app-documentdb-offlinesync-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karolzak%2Fmobile-app-documentdb-offlinesync-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karolzak","download_url":"https://codeload.github.com/karolzak/mobile-app-documentdb-offlinesync-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252989681,"owners_count":21836663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-mobile-apps","csharp","csharp-code","documentdb","incremental-sync","json","mobile","mobile-app","mobile-development","mobile-first","nested-objects","offline-sync","sqlite","uwp","uwp-applications","uwp-dev","xamarin","xamarin-android","xamarin-ios"],"created_at":"2024-10-03T18:37:14.331Z","updated_at":"2025-05-08T02:44:38.598Z","avatar_url":"https://github.com/karolzak.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Azure Mobile Apps using DocumentDb + Incremental and offline sync\n\nThis is a proof of concept project where we tight up a DocumentDB instance with complex (nested) types with several SQLite mobile clients using Azure Mobile Apps with Offline Sync. In this project we are trying to achieve following features:\n\n- [x] Accessing data from DocumentDB on mobile clients through Azure Mobile Apps\n- [x] Ability for mobile clients to work with downloaded data in offline mode\n- [x] Incremental sync on client to download only updated/added/data (limits the data transfer)\n- [x] Support for flat DocumentDB objects\n- [ ] Support for more complex nested objects\n\n\nKey points:\n- [Custom DomainManager for TableController](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentDBDomainManager.cs) - it allows us to sync data on client through Azure Mobile Apps Tables to work with DocumentDB objects\n- Azure Mobile Apps client SDK with offline sync configuration uses \"createdAt\" and \"updatedAt\" attributes to determine which objects needs to be synced. [THESE ARE CASE SENSITIVE!!](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentResource.cs) We learned it the hard way...\n- At this point of time (16.01.2017), Azure Mobile Apps client SDK offline sync feature works only for flat objects. It's not suitable for more complex and nested types\n- Best we could achieve was to implement offline sync for level 1 nested objects similar to this:\n```JSON\n{\n \"text\": \"Mew task ios\",\n \"nested\": {\n   \"nestedText\": \"144 J B Hazra Road\",\n   \"nestedBool\": \"false\"\n },\n \"nestedItems\": [\n   {\n     \"nestedText\": \"xxoxoxoxoxox\",\n     \"nestedBool\": \"true\"\n   }\n ],\n \"complete\": true,\n \"id\": \"8d16700a-fcc0-4453-b740-e3eef8c0c340\",\n \"version\": null,\n \"createdat\": \"2017-01-11T12:27:24.1394782+00:00\",\n \"updatedat\": \"2017-01-11T14:24:03.4335527+00:00\",\n \"deleted\": false\n}\n```\nUnfortunately, nested objects/collections can only be stored as strings/JSON in SQLite store on mobile client: \n![alt text](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/sqlite_stored_data.png \"SQLite data\")\n\nWe achieved this by implementing a [custom Expand attribute](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/QueryableExpandAttribute.cs) to include nested objects when sending data from Azure Mobile App to client.\nWe used it in our TableController [here](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Controllers/ComplexItemController.cs#27)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarolzak%2Fmobile-app-documentdb-offlinesync-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarolzak%2Fmobile-app-documentdb-offlinesync-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarolzak%2Fmobile-app-documentdb-offlinesync-sample/lists"}