{"id":22228,"date":"2018-07-23T16:12:08","date_gmt":"2018-07-23T20:12:08","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=22228"},"modified":"2018-07-23T16:12:08","modified_gmt":"2018-07-23T20:12:08","slug":"schema-less-database-with-dynamic-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/07\/23\/schema-less-database-with-dynamic-swift\/","title":{"rendered":"Schema-less Database With Dynamic Swift"},"content":{"rendered":"<p><a href=\"http:\/\/inessential.com\/2018\/07\/22\/evergreen_diary_10_syncing_feed_data_and\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/inessential.com\/2018\/07\/22\/evergreen_diary_10_syncing_feed_data_and\">\n<p>Persistence was exactly as easy as that: you could get and set values and tables, delete things, etc., and the whole giant nested dictionary was stored on disk as a database.<\/p>\n\n<p>This is <em>exactly<\/em> the kind of thing I want backing my <code>Feed<\/code> objects. I want a Frontier-like database with a table called <code>feeds<\/code>, and a subtable for each individual feed (keyed by feed ID). The table (remember it&rsquo;s like a dictionary) for each feed contains exactly what it needs &mdash; including any arbitrary future stuff I haven&rsquo;t needed or though of yet &mdash; and nothing else. No database migrations ever. Just room to grow.<\/p>\n\n<p>Well &mdash; I&rsquo;ve been working on this for a while, and it&rsquo;s not quite done, but it&rsquo;s close. <a href=\"https:\/\/github.com\/brentsimmons\/RSDatabase\/tree\/master\/RSDatabase\/ODB\">See ODB<\/a>, which is part of my RSDatabase framework.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/clattner_llvm\/status\/1021270248744398849\">Chris Lattner<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/clattner_llvm\/status\/1021270248744398849\">\n<p>Glad to see that dynamicMemberLookup is useful to you!  Hopefully you&rsquo;ll like dynamicCallable too.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0216-dynamic-callable.md\">SE-0216<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0216-dynamic-callable.md\"><p>This proposal is a follow-on to <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0195-dynamic-member-lookup.md\">SE-0195 - Introduce User-defined &ldquo;Dynamic Member\nLookup&rdquo; Types<\/a>\nwhich shipped in Swift 4.2. It introduces a new <code>@dynamicCallable<\/code> attribute, which marks\na type as being &ldquo;callable&rdquo; with normal syntax. It is simple syntactic sugar\nwhich allows the user to write:<\/p><pre>a = someValue(keyword1: 42, \"foo\", keyword2: 19)<\/pre><p>and have it be interpreted by the compiler as:<\/p><pre>a = someValue.dynamicallyCall(withKeywordArguments: [\n    \"keyword1\": 42, \"\": \"foo\", \"keyword2\": 19\n])<\/pre><\/blockquote>\n\n<p>Previously: <a href=\"https:\/\/mjtsai.com\/blog\/2018\/06\/29\/exploring-dynamicmemberlookup\/\">Exploring @dynamicMemberLookup<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: Persistence was exactly as easy as that: you could get and set values and tables, delete things, etc., and the whole giant nested dictionary was stored on disk as a database. This is exactly the kind of thing I want backing my Feed objects. I want a Frontier-like database with a table called [&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":"2018-07-23T20:12:10Z","apple_news_api_id":"038c2a49-b9ec-4cab-b691-b9d3d1ff2620","apple_news_api_modified_at":"2018-07-23T20:12:11Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AA4wqSbnsTKu2kbnT0f8mIA","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":[],"tags":[143,1528,1505,31,46,30,74,425,901,269],"class_list":["post-22228","post","type-post","status-publish","format-standard","hentry","tag-database","tag-evergreen","tag-frontier","tag-ios","tag-languagedesign","tag-mac","tag-opensource","tag-sqlite","tag-swift-programming-language","tag-syncing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22228","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=22228"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22228\/revisions"}],"predecessor-version":[{"id":22229,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/22228\/revisions\/22229"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=22228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=22228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=22228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}