-
Notifications
You must be signed in to change notification settings - Fork 31
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
Swift 2 query method equivalent #53
Comments
for-loop support was removed to make handling errors more compatible with swift 2 errors. Instead of a for-loop, you use the next() method: var results = try db.prepareStatement("SELECT * FROM people")
while try results.next() {
var row = results.dictionaryValue
// or whatever you want to do with the row
} Since it's common to simply transform a row into some object value, you can also use the |
Thank you for your response. |
@Persilos, Bindable is just a protocol, so the underlying value may be any value that implements the Bindable protocol. If you know for sure that all the Bindable values are strings, you can do: These functions are not specific to Squeal, but because Squeal returns Bindable values, you need handle using the returned data correctly. Hope that helps. |
There are also methods that take blocks, prefixed with Something like: let emails = try db.selectFrom("people") { $0["email"] as String }
// equivalent with a statement
let results = try db.prepareStatement("SELECT * FROM people")
let moreEmails = try results.select { $0["email"] as String } |
Thanks :) |
Hi,
I used the query(string) method to make a generic method for select data.
With the update of Squeal for Swift2, i cant use this method.
var rows = try db.query(request)
for row in rows{
//Treat row
}
I dont find equivalent of this...
Regards
The text was updated successfully, but these errors were encountered: