diff --git a/.circleci/config.yml b/.circleci/config.yml index 41fbc80..7024218 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,7 @@ jobs: - run: name: Install dependencies command: | + export HOMEBREW_NO_AUTO_UPDATE=1 brew tap vapor/homebrew-tap brew install cmysql brew install ctls diff --git a/.gitignore b/.gitignore index 3ed19d6..6d8fabc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,7 @@ -*.swp Packages .build -.idea -xcuserdata -*.xcodeproj -Config/secrets/ .DS_Store -node_modules/ -bower_components/ -.swift-version -Package.pins +*.xcodeproj +DerivedData/ Package.resolved +.swiftpm diff --git a/Sources/Sugar/Helpers/Model.swift b/Sources/Sugar/Helpers/Model.swift index ef0e00d..a19a9de 100644 --- a/Sources/Sugar/Helpers/Model.swift +++ b/Sources/Sugar/Helpers/Model.swift @@ -11,7 +11,22 @@ public extension Model { .unwrap(or: Abort(.notFound, reason: "\(Self.self) with id \(id) not found")) } - func saveOrUpdate ( + @available(*, deprecated, message: "use `creatOrUpdate(given:withSoftDeleted:restore:on)`") + func saveOrUpdate( + given filters: [FilterOperator], + withSoftDeleted: Bool = false, + restore: Bool = false, + on db: DatabaseConnectable + ) throws -> Future { + return try createOrUpdate( + given: filters, + withSoftDeleted: withSoftDeleted, + restore: restore, + on: db + ) + } + + func createOrUpdate( given filters: [FilterOperator], withSoftDeleted: Bool = false, restore: Bool = false, @@ -25,7 +40,7 @@ public extension Model { return query.first().flatMap(to: Self.self) { result in guard let result = result else { - return self.save(on: db) + return self.create(on: db) } var copy = self