{"id":15444,"date":"2016-07-28T11:54:33","date_gmt":"2016-07-28T15:54:33","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=15444"},"modified":"2017-05-03T15:15:02","modified_gmt":"2017-05-03T19:15:02","slug":"grdb-swift-sqlite-orm","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/07\/28\/grdb-swift-sqlite-orm\/","title":{"rendered":"GRDB Swift SQLite ORM"},"content":{"rendered":"<p><a href=\"https:\/\/medium.com\/@gwendal.roue\/how-to-build-an-ios-application-with-sqlite-and-grdb-swift-d023a06c29b3\">Gwendal Rou&eacute;<\/a>:<\/p>\n<blockquote cite=\"https:\/\/medium.com\/@gwendal.roue\/how-to-build-an-ios-application-with-sqlite-and-grdb-swift-d023a06c29b3\"><p><a href=\"http:\/\/github.com\/groue\/GRDB.swift\">GRDB.swift<\/a> is a Swift application toolkit that provides access to <a href=\"http:\/\/sqlite.org\">SQLite<\/a> databases.<\/p><p>[&#8230;]<\/p><p>GRDB is protocol-oriented, and fetching methods are proper to the <a href=\"https:\/\/github.com\/groue\/GRDB.swift#rowconvertible-protocol\">RowConvertible<\/a> protocol.<\/p><p>[&#8230;]<\/p><p>This makes GRDB quite unlike other Swift ORMs that use class inheritance and make heavy use of objects mutability, like <a href=\"http:\/\/realm.io\">Realm<\/a> and <a href=\"https:\/\/developer.apple.com\/library\/watchos\/documentation\/Cocoa\/Conceptual\/CoreData\/index.html\">Core Data<\/a>. Both of them provide uniquing and auto-updating records.<\/p><\/blockquote>\n\n<p>Update (2017-05-03): <a href=\"https:\/\/medium.com\/@gwendal.roue\/unexpected-sqlite-with-swift-ddc6343bcbfc\">Gwendal Rou&eacute;<\/a>:<\/p>\n<blockquote cite=\"https:\/\/medium.com\/@gwendal.roue\/unexpected-sqlite-with-swift-ddc6343bcbfc\"><p>SQLite provides <a href=\"https:\/\/sqlite.org\/c3ref\/update_hook.html\">Data Change Notification Callbacks<\/a>, and <a href=\"https:\/\/sqlite.org\/c3ref\/set_authorizer.html\">Compile-Time Authorization Callbacks<\/a>. The first notify of modified rows, when the latter tell which tables and columns are involved in an SQL statement.<\/p><p>When you combine them, you are able to tell if an SQL statement has the opportunity to affect the results of another query. This is the recipe for database observation through <a href=\"http:\/\/github.com\/RxSwiftCommunity\/RxGRDB\">RxGRDB<\/a> (a reactive extension for GRDB over RxSwift), or <a href=\"https:\/\/github.com\/groue\/GRDB.swift#fetchedrecordscontroller\">FetchedRecordsController<\/a> (a Swift version of Core Data&rsquo;s NSFetchedResultsController).<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Gwendal Rou&eacute;: GRDB.swift is a Swift application toolkit that provides access to SQLite databases.[&#8230;]GRDB is protocol-oriented, and fetching methods are proper to the RowConvertible protocol.[&#8230;]This makes GRDB quite unlike other Swift ORMs that use class inheritance and make heavy use of objects mutability, like Realm and Core Data. Both of them provide uniquing and auto-updating [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[143,1412,74,71,425,901],"class_list":["post-15444","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-database","tag-grdb","tag-opensource","tag-programming","tag-sqlite","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=15444"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15444\/revisions"}],"predecessor-version":[{"id":17878,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15444\/revisions\/17878"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=15444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=15444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=15444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}