Monday, July 23, 2018

Schema-less Database With Dynamic Swift

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 feeds, and a subtable for each individual feed (keyed by feed ID). The table (remember it’s like a dictionary) for each feed contains exactly what it needs — including any arbitrary future stuff I haven’t needed or though of yet — and nothing else. No database migrations ever. Just room to grow.

Well — I’ve been working on this for a while, and it’s not quite done, but it’s close. See ODB, which is part of my RSDatabase framework.

Chris Lattner:

Glad to see that dynamicMemberLookup is useful to you! Hopefully you’ll like dynamicCallable too.

SE-0216:

This proposal is a follow-on to SE-0195 - Introduce User-defined “Dynamic Member Lookup” Types which shipped in Swift 4.2. It introduces a new @dynamicCallable attribute, which marks a type as being “callable” with normal syntax. It is simple syntactic sugar which allows the user to write:

a = someValue(keyword1: 42, "foo", keyword2: 19)

and have it be interpreted by the compiler as:

a = someValue.dynamicallyCall(withKeywordArguments: [
    "keyword1": 42, "": "foo", "keyword2": 19
])

Previously: Exploring @dynamicMemberLookup.

1 Comment RSS · Twitter


[…] Schema-less Database With Dynamic Swift, Exploring […]

Leave a Comment