Releases: vapor/fluent
Fluent 2.0 Alpha 4
New:
- Storable base to allow easier protocol extensions
- IdKey conveniences
Changed:
- Fluent now enforces reference types, use
final class
in place ofstruct
on existing conformers. - Swift 3.1
Warning:
- id and exists are now implemented natively by Fluent, this means a few changes are required. All instances of
var id: Node?
andvar exists
on models MUST be deleted for Fluent to function properly. - if you are setting
id
manually in initializers, it MUST happen AFTER the initialization to function properly. In practice, this means usually putid = ...
at the BOTTOM of your initializer if you need to do it.
let name: String
init(node: Node, in context: Context) throws {
id = try node.extract("id") // will fail
name = try node.extract("name")
}
=>
let name: String
init(node: Node, in context: Context) throws {
name = try node.extract("name")
// called after initialization proper
id = try node.extract("id")
}
Fluent 2.0 Alpha 3.1
New:
- Ability to specify primary key fields.
Fluent 2.0 Alpha 3
Relations
Relations have been updated to include both entities in the generic signature. This will allow Fluent to access more type information on the related entities to perform more functions in the future.
PivotProtocol
Introduces a new pivot protocol that will allow making custom pivot tables easier. For example, storing the amount of upvotes on a Pivot<User, Comments>
.
Union -> Join
The misleadingly named Union is renamed to Join
Foreign / Local clarification
The terms foreign and local have been used somewhat haphazardly in Fluent. The formal definition states:
In the context of relational databases, a foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table or the same table. In simpler words, the foreign key is defined in a second table, but it refers to the primary key in the first table.
Usage in Fluent has been updated to reflect this.
Double Pivot
Some code has been added to allow 3 way pivot relation checking for pivots that have another pivot stored in either side. For example:
let doublePivot = Pivot<
Pivot<Users, Teams>,
Roles
>
let user = Users.random()
let team = Teams.random()
let role = Roles.random()
let related = try doublePivot.related(left: user, middle: team, right: role)
Fluent 2.0 Alpha 2
New:
- Entities can apply custom ID Keys.
Custom ID Key
You can override the idKey
for an individual entity by implement static var idKey: String
on your model. Fluent will now use this id key for fetching your model, saving, etc (instead of the driver's id key).
final class MyUser: Entity {
...
static var idKey = "fooid"
}
Note: Preparations still require a custom
idKey
to be passed.
extension MyUser {
static func prepare(_ database: Database) throws {
try database.create(entity) { myUsers in
myUsers.id(idKey)
...
}
}
}
Fluent 1.4.0
New:
- Entities can apply custom ID Keys.
- in memory db issue
Custom ID Key
You can override the idKey
for an individual entity by implement static var idKey: String
on your model. Fluent will now use this id key for fetching your model, saving, etc (instead of the driver's id key).
final class MyUser: Entity {
...
static var idKey = "fooid"
}
Note: Preparations still require a custom
idKey
to be passed.
extension MyUser {
static func prepare(_ database: Database) throws {
try database.create(entity) { myUsers in
myUsers.id(idKey)
...
}
}
}
Fluent 1.3.8
Fixed:
- Fix bug where In-Memory DB limit was causing Array out-of-bounds crash
Fluent 2.0 Alpha 1
New:
- Updated to include raw commands
- Updated underlying dependencies to latest versions
- Date Support
Fluent 1.3.7
New:
- Allow custom id keys for parent
Fluent 1.3.6
Fixed:
- Ignore
nil
,Node.null
, and0
values for newly created model identifiers.
Fluent 1.3.5
New:
DatabaseContext
now passed toinit(node: ...)
andmakeNode(...)