From c5405071c6794ee2e240d36fb6281302fa0cfb0c Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Thu, 6 Feb 2020 16:27:48 +0100 Subject: [PATCH 1/5] Use create instead of save This allows specifying an id --- Sources/Sugar/Helpers/Model.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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 From 03f66af17d17c78fe7d4509949cbabee5a32bdcd Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Thu, 6 Feb 2020 16:42:35 +0100 Subject: [PATCH 2/5] Select ruby version 2.6 --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 41fbc80..d71f89e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,9 @@ jobs: - restore_cache: keys: - macos-swift4.2-v1-spm-deps-{{ checksum "Package.swift" }} + - run: + name: Set Ruby Version + command: echo 'chruby ruby-2.6' >> ~/.bash_profile - run: name: Install dependencies command: | From d2633c51ed6512eac35a38b12cfe496c6dff7a3f Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Fri, 7 Feb 2020 10:10:52 +0100 Subject: [PATCH 3/5] Do not auto update homebrew --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d71f89e..c64aab7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,7 @@ jobs: - run: name: Install dependencies command: | + export HOMEBREW_NO_AUTO_UPDATE=1 brew tap vapor/homebrew-tap brew install cmysql brew install ctls From a2f717763f230e302594ed3a0255186ffb4893f8 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Fri, 7 Feb 2020 12:04:18 +0100 Subject: [PATCH 4/5] Remove ruby version step --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c64aab7..7024218 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,9 +8,6 @@ jobs: - restore_cache: keys: - macos-swift4.2-v1-spm-deps-{{ checksum "Package.swift" }} - - run: - name: Set Ruby Version - command: echo 'chruby ruby-2.6' >> ~/.bash_profile - run: name: Install dependencies command: | From 085b0bd6f94d4b33881eadb34456751bae431706 Mon Sep 17 00:00:00 2001 From: Siemen Sikkema Date: Fri, 7 Feb 2020 12:04:32 +0100 Subject: [PATCH 5/5] Update gitignore --- .gitignore | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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