Server Side Swift with Kitura by David Okun & Chris Bailey
Author:David Okun & Chris Bailey
Language: eng
Format: epub
Publisher: Ray Wenderlich
More complex database queries
As you’ve seen in this chapter, SwiftKueryORM makes it very easy to persist, fetch, update and delete objects from a database without having to work directly with the database or build SQL queries.
However, some apps will need to perform more complex tasks. Specifically, you’ll sometimes want to be able to craft custom SQL queries. Kitura has you covered here as well.
SwiftKueryORM itself is built on a set of lower-level APIs from the SwiftKuery module — a library for building SQL queries in a type-safe manner. This means rather than creating a raw SQL query — an error-prone and potentially dangerous proposition — you can instead use native Swift tools to do this safely, with the compiler’s help.
For example, instead of issuing this raw SQL:
SELECT id, emoji, date FROM journalentry WHERE emoji = "😁";
You could instead write this line of Swift:
let query = Select(entry.id, entry.emoji, entry.date, from: entries).where(entry.emoji = "😁")
Here’s the really nice thing about this implementation: The methods added to your types when you conform them to Model use SwiftKuery in their implementations. This means that you can choose to override these methods with custom queries any time you have need to do so.
You get the convenience of SwiftKueryORM’s convenience methods most of the time and the ability to easily drop down into SQL whenever the need arises!
Before continuing, return to Xcode and stop your server. You’re doing this because, while your project runs in Xcode, it listens on port 8080. You’ll need to have this port available for your Docker image to run in the next section (otherwise, attempts to run it would fail because of the port conflict).
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12585)
Hello! Python by Anthony Briggs(9920)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9799)
The Mikado Method by Ola Ellnestam Daniel Brolund(9782)
Dependency Injection in .NET by Mark Seemann(9343)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8305)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7768)
Grails in Action by Glen Smith Peter Ledbrook(7700)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7562)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7121)
Microservices with Go by Alexander Shuiskov(6882)
Practical Design Patterns for Java Developers by Miroslav Wengner(6800)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6744)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6420)
Angular Projects - Third Edition by Aristeidis Bampakos(6155)
The Art of Crafting User Stories by The Art of Crafting User Stories(5681)
NetSuite for Consultants - Second Edition by Peter Ries(5612)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5423)
Kotlin in Action by Dmitry Jemerov(5070)
