pe persis istin ing g data wit ith realm mobil ile
play

PE PERSIS ISTIN ING G DATA WIT ITH REALM MOBIL ILE DATABASE - PowerPoint PPT Presentation

PE PERSIS ISTIN ING G DATA WIT ITH REALM MOBIL ILE DATABASE Adam Fisher Application Developer Integrated Web & Mobile Solutions Team CareSource Xamarin Certified Mobile Developer May 2015 May 2016 July 2017 July


  1. PE PERSIS ISTIN ING G DATA WIT ITH REALM MOBIL ILE DATABASE

  2. Adam Fisher • Application Developer Integrated Web & Mobile Solutions Team CareSource • Xamarin Certified Mobile Developer • May 2015 – May 2016 • July 2017 – July 2018 @calmtuna • Author of the Xamarin Forms Video Player component @adamgfisher • Worked with for 8 months in Chicago /adamfisher • Currently working on the CareSource mobile app

  3. Outline • Existing Mobile Persistence Solutions • Benefits of a Mobile Database • What is Realm? • Code Examples • Questions

  4. Existing Persistence Solutions KEY/VALUE STORAGE DATABASE STORAGE • iOS: NSUserDefaults • Android: SharedPreferences • React Native: AsyncStorage • Xamarin: Xamarin.Essentials

  5. Realm SQLite Object Oriented Database Relational Database Cross-Platform Cross-Platform Objects Tables, Indexes, Views Remote Cloud Sync X Built-in Encryption X Live Objects X

  6. await AsyncStorage.setItem(’ApplicationData', '{ "data": [ { "id": 1, "name": "Bitcoin", "symbol": "BTC", "website_slug": "bitcoin" }, { "id": 2, "name": "Litecoin", "symbol": "LTC", "website_slug": "litecoin" }, { "id": 3, "name": "Namecoin", "symbol": "NMC", "website_slug": "namecoin" }, { "id": 4, "name": "Terracoin", "symbol": "TRC", "website_slug": "terracoin" }, { "id": 5, "name": "Peercoin", "symbol": "PPC", "website_slug": "peercoin" }, { "id": 6, "name": "Novacoin", "symbol": "NVC", "website_slug": "novacoin" }, { "id": 8, "name": "Feathercoin", "symbol": "FTC", "website_slug": "feathercoin" }, { "id": 9, "name": "Mincoin", "symbol": "MNC", "website_slug": "mincoin" }, { "id": 10, "name": "Freicoin", "symbol": "FRC", "website_slug": "freicoin" }, { "id": 13, "name": "Ixcoin", "symbol": "IXC", "website_slug": "ixcoin" }, { "id": 14, "name": "BitBar", "symbol": "BTB", "website_slug": "bitbar" }, { "id": 16, "name": "WorldCoin", "symbol": "WDC", "website_slug": "worldcoin" }, { "id": 18, "name": "Digitalcoin", "symbol": "DGC", "website_slug": "digitalcoin" }, { "id": 25, "name": "GoldCoin", "symbol": "GLD", "website_slug": "goldcoin" }, { "id": 31, "name": "Argentum", "symbol": "ARG", "website_slug": "argentum" }, { "id": 32, "name": "Fastcoin", "symbol": "FST", "website_slug": "fastcoin" }, { "id": 34, "name": "Bitgem", "symbol": "BTG", "website_slug": "bitgem" }, { "id": 35, "name": "Phoenixcoin", "symbol": "PXC", "website_slug": "phoenixcoin" }, { "id": 37, "name": "Megacoin", "symbol": "MEC", "website_slug": "megacoin" }, { "id": 41, "name": "Infinitecoin", "symbol": "IFC", "website_slug": "infinitecoin" }, { "id": 42, "name": "Primecoin", "symbol": "XPM", "website_slug": "primecoin" }, { "id": 43, "name": "Anoncoin", "symbol": "ANC", "website_slug": "anoncoin" }, { "id": 45, "name": "CasinoCoin", "symbol": "CSC", "website_slug": "casinocoin" }, { "id": 49, "name": "Bullion", "symbol": "CBX", "website_slug": "bullion" }, { "id": 50, "name": "Emerald Crypto", "symbol": "EMD", "website_slug": "emerald" }, { "id": 51, "name": "GlobalCoin", "symbol": "GLC", "website_slug": "globalcoin" }, { "id": 52, "name": "XRP", "symbol": "XRP", "website_slug": "ripple" }, { "id": 53, "name": "Quark", "symbol": "QRK", "website_slug": "quark" }, { "id": 56, "name": "Zetacoin", "symbol": "ZET", "website_slug": "zetacoin" }, { "id": 57, "name": "SecureCoin", "symbol": "SRC", "website_slug": "securecoin" }, { "id": 58, "name": "Sexcoin", "symbol": "SXC", "website_slug": "sexcoin" }, { "id": 61, "name": "TagCoin", "symbol": "TAG", "website_slug": "tagcoin" }, { "id": 63, "name": "I0Coin", "symbol": "I0C", "website_slug": "i0coin" }, { "id": 64, "name": "FlorinCoin", "symbol": "FLO", "website_slug": "florincoin" }, { "id": 66, "name": "Nxt", "symbol": "NXT", "website_slug": "nxt" }, { "id": 67, "name": "Unobtanium", "symbol": "UNO", "website_slug": "unobtanium" } ], "metadata": { "timestamp": 1532545712, "num_cryptocurrencies": 66, "error": null } }');

  7. Realm, Inc. • Danish startup founded in 2011 • Native object oriented database • Used to be called TightDB

  8. What is a Realm? • A Realm is a lightweight object container that acts like a database • Data can be queried, filtered, interconnected, persisted • Live/Reactive objects • Can contain multiple types with schema enforcement

  9. Benefits of a database built for mobile Offline-First Functionality Cross-Platform Apps Make your app work as well offline Use the same database for all your as it does online. apps, on any major platform. Encryption Fast Queries Even complex queries take Secure your data with transparent nanoseconds, and stay up to date encryption and decryption. with new data. Reactive Architecture Safe Threading Connect your UI to Realm, and Access the same data concurrently data changes will appear from multiple threads, with no automatically. crashes.

  10. Supported Platforms

  11. Correlation Realm Relational Database Database /Connection Realm Table Schema Row Object Column Object.Property

  12. Re Realm St Studio • Open and edit local and synced Realms • Administer any Realm Object Server instance • Available for Mac, Windows, Linux

  13. Supported Types (JavaScript) Types Maps To JavaScript Boolean values bool JavaScript number values int, float, double Internally int and double are stored as 64 bits while float is stored with 32 bits string string ArrayBuffer data Date date

  14. Query Language • Inspired by NSPredicate • Query Language: https://realm.io/docs/javascript/latest/api/tutorial-query-language.html • Cheat Sheet: https://bit.ly/2nrwC7S

  15. Fo Format String Su Summary

  16. Ba Basic c Com Comparison ons

  17. Ba Basic c Com Compou ound Pr Predicates

  18. Str String Com Comparison on Op Operators

  19. Ag Aggregate Op Operators

  20. Un Unsupported Op Operations

  21. Un Unsupported Op Operations

  22. • Using OR OR OR instead of IN , results in repeatable code Ti Tips s & Tricks and can be less efficient. • When using REGEX and Matches , make sure they are the last part of your predicate statement so it does less work. • Write transactions have a non-negligible overhead; you should try to minimize the number of write blocks within your code.

  23. Define the Objects in Your Schema const PersonSchema = { name : 'Person' , primaryKey : 'id' , properties : { id : 'int' , // primary key firstName : 'string' , lastName : 'string' } };

  24. Define the Objects in Your Schema const CryptocurrencySchema = { name : 'Cryptocurrency' , primaryKey : 'symbol' , properties : { name : { type : 'string' , indexed : true }, symbol : 'string' , price : 'double?' , marketCap : { type : 'int' , default : 0 }, founder : 'Person' } };

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend