Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Swift 4 Encoder Decoder #29

Open
patrick-zippenfenig opened this issue Oct 4, 2017 · 2 comments
Open

[Feature request] Swift 4 Encoder Decoder #29

patrick-zippenfenig opened this issue Oct 4, 2017 · 2 comments

Comments

@patrick-zippenfenig
Copy link

Hi,
I recently stumbled across this library and startet to wonder if it would be possible to use new Swift 4 Encoder and Decoder as some sort of ORM.
Select statements could directly populate structs/objects.

struct MyTable {
  var iint8 : Int8 = -1
  var uint8: UInt8 = 1
  var int16 : Int16 = -1
}

let table = MySQL.Table(tableName: "my_table", connection: con)
let row = try table.select(Where: ["id=", 90])

let decoder = MySQL.Decoder()
let my_table = try! decoder.decode(MyTable.self, for: row)

Would such a feature be possible? Or are there limitations?

Regards,
Patrick

@mcorega
Copy link
Owner

mcorega commented Oct 18, 2017

take a look at the latest version. In MySQLSampleOSX you will find a working example.

@patrick-zippenfenig
Copy link
Author

Nice. Although performance does not look ideal.
I opened another feature request at mysql-swift library and provided some example code for Decodeable: novi/mysql-swift#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants