Skip to content

Commit

Permalink
Added Model.hasChanges property (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebkleveter authored Jan 16, 2020
1 parent 877bf49 commit d3bb891
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/FluentKit/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ private struct ContainerEncoder: Encoder, SingleValueEncodingContainer {
}

extension Model {

/// Indicates whether the model has fields that have been set, but the model has not yet been saved to the database.
public var hasChanges: Bool {
return !self.input.isEmpty
}

public static func key<Field>(for field: KeyPath<Self, Field>) -> String
where Field: FieldRepresentable
{
Expand Down

0 comments on commit d3bb891

Please sign in to comment.