Swiftpack.co - Package - vapor/sql

Github

link
Stars: 68
Help us keep the lights on

Dependencies

Releases

2.0.2 - Jul 17, 2018

Fixed:

  • Added missing methods to SQLSelectExpression.

2.0.1 - Jul 16, 2018

Fixed:

  • CREATE INDEX no longer incorrectly serializes column names.

2.0.0 - Jul 16, 2018

Protocols:

  • The query structures this package exposes have been protocolized to allow for better support of custom SQL dialects. Instead of using concrete types like struct and enum, this package now exposes protocols defining SQL capabilities. Specific SQL dialects can now create custom implementations of these protocols with additional stored properties or methods for supporting native functionality.

No serializers:

  • Now that the query structures are protocolized, types can be responsible for serializing themselves. This greatly reduces the amount of code needed to serialize the SQL and keeps code organized.

New query builders:

  • This package now exposes helpers for building the various SQL queries. This is a great way to build lower level queries without needing to resort to SQL strings.
let users = conn.select()
    .all().from(User.self)
    .where(\User.name == "Vapor")
    .all(decoding: User.self)
print(users) // Future<[User]>

The above code would result in a SQL query like:

SELECT * FROM "users" WHERE "users"."name" = ?

See the updated documentation for more information: docs.vapor.codes/3.0/sql/getting-started/

And of course, check out the API docs for detailed information about the public API: api.vapor.codes/sql/latest/SQL/

2.0.0-beta.3 - Jun 22, 2018

New:

  • Added SQLCreateIndex and SQLDropIndex queries (#16).
  • New SQLCreateIndexBuilder for creating indexes on your database (#16).
conn.create(index: "planets_idx", on: \Planet.name).unique().run()

note: There is unfortunately no SQL standard for the DROP INDEX query so each SQL driver will be implementing their own drop index builder with custom syntax.

2.0.0-beta.1.0.1 - Jun 21, 2018