diff --git a/ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift index b6f8cdc0d..6ec989cb4 100644 --- a/ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift @@ -41,7 +41,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, @@ -79,7 +82,10 @@ struct GameData: ParseObject { //: or else you will need your masterKey to force an upgrade. var bytes: ParseBytes? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if shouldRestoreKey(\.polygon, @@ -120,10 +126,13 @@ score.save { result in assert(savedScore.updatedAt != nil) assert(savedScore.points == 10) - /*: To modify, need to make it a var as the value type - was initialized as immutable. Using `mergeable` - allows you to only send the updated keys to the - parse server as opposed to the whole object. + /*: + To modify, you need to make it a var as the value type + was initialized as immutable. Using `mergeable` + allows you to only send the updated keys to the + parse server as opposed to the whole object. Make sure + to call `mergeable` before you begin + your first mutation of your `ParseObject`. */ var changedScore = savedScore.mergeable changedScore.points = 200 @@ -210,15 +219,18 @@ assert(savedScore?.createdAt != nil) assert(savedScore?.updatedAt != nil) assert(savedScore?.points == 10) -/*: To modify, need to make it a var as the value type - was initialized as immutable. Using `mergeable` - allows you to only send the updated keys to the - parse server as opposed to the whole object. +/*: + To modify, you need to make a mutable copy of `savedScore`. + Instead of using `mergeable` this time, we will use the `set()` + method which allows us to accomplish the same thing + as `mergeable`. You can choose to use `set()` or + `mergeable` as long as you use either before you begin + your first mutation of your `ParseObject`. */ -guard var changedScore = savedScore?.mergeable else { +guard var changedScore = savedScore else { fatalError("Should have produced mutable changedScore") } -changedScore.points = 200 +changedScore = changedScore.set(\.points, to: 200) let savedChangedScore: GameScore? do { diff --git a/ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift index 6d21bb758..15ddd13d6 100644 --- a/ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift @@ -144,7 +144,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift index 4891bbe9f..1884da1f1 100644 --- a/ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift @@ -23,7 +23,10 @@ struct GameScore: ParseObject { var location: ParseGeoPoint? var name: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift index 4418652a1..2b8bf9415 100644 --- a/ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift @@ -32,7 +32,10 @@ struct User: ParseUser { var customKey: String? var scores: ParseRelation? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, @@ -55,7 +58,10 @@ struct Role: ParseRole { //: Provided by Role. var name: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.name, @@ -78,7 +84,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift index c52014654..96199c7cb 100644 --- a/ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift @@ -25,7 +25,10 @@ struct GameScore: ParseObject { var points: Int? var name: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift index 1cf838030..5829c5c67 100644 --- a/ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift @@ -34,7 +34,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, @@ -79,10 +82,11 @@ score.save { result in //: Any changes to `createdAt` and `objectId` will not be saved to the server. print("Saved score: \(savedScore)") - /*: To modify, need to make it a var as the value type - was initialized as immutable. Using `.mergeable` - allows you to only send the updated keys to the - parse server as opposed to the whole object. + /*: + To modify, need to make it a var as the value type + was initialized as immutable. Using `.mergeable` or `set()` + allows you to only send the updated keys to the + parse server as opposed to the whole object. */ var changedScore = savedScore.mergeable changedScore.points = 200 diff --git a/ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift index ce353c461..0b550d687 100644 --- a/ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift @@ -33,7 +33,10 @@ struct GameScore: ParseObject { var name: String? var myFiles: [ParseFile]? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift index 32157e197..213ed2dc0 100644 --- a/ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift @@ -33,7 +33,10 @@ struct GameScore: ParseObject { var location: ParseGeoPoint? var name: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift index c1e572c1a..e91472a9b 100644 --- a/ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift @@ -31,7 +31,10 @@ struct GameScore: ParseObject { var location: ParseGeoPoint? var name: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift index a3bca582a..c6f7fedcc 100644 --- a/ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift @@ -26,7 +26,10 @@ struct GameScore: ParseObject { var oldScore: Int? var isHighest: Bool? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/20 - Cloud Schemas.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/20 - Cloud Schemas.xcplaygroundpage/Contents.swift index a588a0051..fdeb48327 100644 --- a/ParseSwift.playground/Pages/20 - Cloud Schemas.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/20 - Cloud Schemas.xcplaygroundpage/Contents.swift @@ -32,7 +32,10 @@ struct User: ParseUser { //: Your custom keys. var customKey: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, @@ -59,7 +62,10 @@ struct GameScore2: ParseObject { var owner: User? var rivals: [User]? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/21 - Cloud Push Notifications.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/21 - Cloud Push Notifications.xcplaygroundpage/Contents.swift index 8ede40f46..1a4983550 100644 --- a/ParseSwift.playground/Pages/21 - Cloud Push Notifications.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/21 - Cloud Push Notifications.xcplaygroundpage/Contents.swift @@ -37,7 +37,10 @@ struct Installation: ParseInstallation { //: Your custom keys var customKey: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, diff --git a/ParseSwift.playground/Pages/23 - Cloud Hook Triggers.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/23 - Cloud Hook Triggers.xcplaygroundpage/Contents.swift index 338ce4eb4..86fdf29d9 100644 --- a/ParseSwift.playground/Pages/23 - Cloud Hook Triggers.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/23 - Cloud Hook Triggers.xcplaygroundpage/Contents.swift @@ -25,7 +25,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/3 - User - Sign Up.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/3 - User - Sign Up.xcplaygroundpage/Contents.swift index 83e898a4a..40c533c45 100644 --- a/ParseSwift.playground/Pages/3 - User - Sign Up.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/3 - User - Sign Up.xcplaygroundpage/Contents.swift @@ -31,7 +31,10 @@ struct User: ParseUser { //: Your custom keys. var customKey: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, diff --git a/ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift index a9834d77d..1008dbd15 100644 --- a/ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift @@ -34,7 +34,10 @@ struct User: ParseUser { var targetScore: GameScore? var allScores: [GameScore]? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, @@ -80,7 +83,10 @@ struct GameScore: ParseObject { //: Your own properties. var points: Int? = 0 - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, @@ -112,9 +118,10 @@ do { print("Error logging out: \(error)") } -/*: Login - asynchronously - Performs work on background - queue and returns to specified callbackQueue. - If no callbackQueue is specified it returns to main queue. +/*: + Login - asynchronously - Performs work on background + queue and returns to specified callbackQueue. + If no callbackQueue is specified it returns to main queue. */ User.login(username: "hello", password: "world") { result in @@ -133,17 +140,21 @@ User.login(username: "hello", password: "world") { result in } } -/*: Save your first `customKey` value to your `ParseUser` - Asynchrounously - Performs work on background - queue and returns to specified callbackQueue. - If no callbackQueue is specified it returns to main queue. - Using `.mergeable` allows you to only send the updated keys to the - parse server as opposed to the whole object. +/*: + Save your first `customKey` value to your `ParseUser` + Asynchrounously - Performs work on background + queue and returns to specified callbackQueue. + If no callbackQueue is specified it returns to main queue. + Using `.mergeable` or `set()` allows you to only send + the updated keys to the parse server as opposed to the + whole object. You can chain set calls or even use + `set()` in combination with mutating the `ParseObject` + directly. */ -var currentUser = User.current?.mergeable -currentUser?.customKey = "myCustom" -currentUser?.gameScore = GameScore(points: 12) -currentUser?.targetScore = GameScore(points: 100) +var currentUser = User.current? + .set(\.customKey, to: "myCustom") + .set(\.gameScore, to: GameScore(points: 12)) + .set(\.targetScore, to: GameScore(points: 100)) currentUser?.allScores = [GameScore(points: 5), GameScore(points: 8)] currentUser?.save { result in diff --git a/ParseSwift.playground/Pages/5 - ACL.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/5 - ACL.xcplaygroundpage/Contents.swift index 162e5875b..7166a635b 100644 --- a/ParseSwift.playground/Pages/5 - ACL.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/5 - ACL.xcplaygroundpage/Contents.swift @@ -34,7 +34,10 @@ struct GameScore: ParseObject { //: Your own properties var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/6 - Installation.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/6 - Installation.xcplaygroundpage/Contents.swift index 87670a009..8701ab143 100644 --- a/ParseSwift.playground/Pages/6 - Installation.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/6 - Installation.xcplaygroundpage/Contents.swift @@ -37,7 +37,10 @@ struct Installation: ParseInstallation { //: Your custom keys var customKey: String? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.customKey, @@ -65,10 +68,13 @@ currentInstallation?.save { results in } } -/*: Update your `ParseInstallation` `customKey` and `channels` values. - Performs work on background queue and returns to designated on - designated callbackQueue. If no callbackQueue is specified it - returns to main queue. +/*: + Update your `ParseInstallation` `customKey` and `channels` values. + Performs work on background queue and returns to designated on + designated callbackQueue. If no callbackQueue is specified it + returns to main queue. Using `.mergeable` or `set()` + allows you to only send the updated keys to the + parse server as opposed to the whole object. */ var installationToUpdate = Installation.current?.mergeable installationToUpdate?.customKey = "myCustomInstallationKey2" diff --git a/ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift index fb21a1620..181c03f50 100644 --- a/ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift @@ -26,7 +26,10 @@ struct GameScore: ParseObject { //: Your own properties var points: Int? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/ParseSwift.playground/Pages/8 - Pointers.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/8 - Pointers.xcplaygroundpage/Contents.swift index 68cb47cb7..c5e0b9e29 100644 --- a/ParseSwift.playground/Pages/8 - Pointers.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/8 - Pointers.xcplaygroundpage/Contents.swift @@ -27,7 +27,10 @@ struct Book: ParseObject, ParseQueryScorable { var title: String? var relatedBook: Pointer? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.title, @@ -64,7 +67,10 @@ struct Author: ParseObject { var book: Book? var otherBooks: [Book]? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.name, @@ -221,7 +227,11 @@ do { switch results { case .success(let author): print("Found author and included \"book\": \(author)") - //: Setup related books. + /*: + Setup related books. Using `.mergeable` or `set()` + allows you to only send the updated keys to the + parse server as opposed to the whole object. + */ var modifiedNewBook = newBook.mergeable modifiedNewBook.relatedBook = try? author.otherBooks?.first?.toPointer() diff --git a/ParseSwift.playground/Pages/9 - Files.xcplaygroundpage/Contents.swift b/ParseSwift.playground/Pages/9 - Files.xcplaygroundpage/Contents.swift index b788dfbcf..0b718f45b 100644 --- a/ParseSwift.playground/Pages/9 - Files.xcplaygroundpage/Contents.swift +++ b/ParseSwift.playground/Pages/9 - Files.xcplaygroundpage/Contents.swift @@ -27,7 +27,10 @@ struct GameScore: ParseObject { var profilePicture: ParseFile? var myData: ParseFile? - //: Implement your own version of merge + /*: + Optional - implement your own version of merge + for faster decoding after updating your `ParseObject`. + */ func merge(with object: Self) throws -> Self { var updated = try mergeParse(with: object) if updated.shouldRestoreKey(\.points, diff --git a/Sources/ParseSwift/Documentation.docc/ParseSwift.md b/Sources/ParseSwift/Documentation.docc/ParseSwift.md index 7b8833cb9..a58992d85 100644 --- a/Sources/ParseSwift/Documentation.docc/ParseSwift.md +++ b/Sources/ParseSwift/Documentation.docc/ParseSwift.md @@ -9,9 +9,13 @@ To learn how to use or experiment with ParseSwift, you can run and edit the [Par ## Topics -### Initialize the SDK +### Configure SDK - ``ParseSwift/initialize(configuration:)`` - ``ParseSwift/initialize(applicationId:clientKey:masterKey:serverURL:liveQueryServerURL:allowingCustomObjectIds:usingTransactions:usingEqualQueryConstraint:usingPostForQuery:keyValueStore:requestCachePolicy:cacheMemoryCapacity:cacheDiskCapacity:usingDataProtectionKeychain:deletingKeychainIfNeeded:httpAdditionalHeaders:maxConnectionAttempts:authentication:)`` - ``ParseSwift/initialize(applicationId:clientKey:masterKey:serverURL:liveQueryServerURL:allowingCustomObjectIds:usingTransactions:usingEqualQueryConstraint:usingPostForQuery:keyValueStore:requestCachePolicy:cacheMemoryCapacity:cacheDiskCapacity:migratingFromObjcSDK:usingDataProtectionKeychain:deletingKeychainIfNeeded:httpAdditionalHeaders:maxConnectionAttempts:authentication:)`` - +- ``ParseSwift/configuration`` +- ``ParseSwift/setAccessGroup(_:synchronizeAcrossDevices:)`` +- ``ParseSwift/updateAuthentication(_:)`` +- ``ParseSwift/clearCache()`` +- ``ParseSwift/deleteObjectiveCKeychain()`` diff --git a/Sources/ParseSwift/Types/ParseOperation.swift b/Sources/ParseSwift/Types/ParseOperation.swift index e9aaa7d15..3e60051e7 100644 --- a/Sources/ParseSwift/Types/ParseOperation.swift +++ b/Sources/ParseSwift/Types/ParseOperation.swift @@ -38,7 +38,7 @@ public struct ParseOperation: Savable where T: ParseObject { `func set(_ key: (String, WritableKeyPath), value: W?)` instead. */ - @available(*, deprecated, message: "replace \"value\" with \"to\"") + @available(*, deprecated, message: "Replace \"value\" with \"to\"") public func set(_ keyPath: WritableKeyPath, value: W) throws -> Self where W: Encodable & Equatable { try set(keyPath, to: value) @@ -81,7 +81,7 @@ public struct ParseOperation: Savable where T: ParseObject { - returns: The updated operations. - Note: Set the value to "nil" if you want it to be "null" on the Parse Server. */ - @available(*, deprecated, message: "replace \"value\" with \"to\"") + @available(*, deprecated, message: "Replace \"value\" with \"to\"") public func set(_ key: (String, WritableKeyPath), value: W?) -> Self where W: Encodable & Equatable { set(key, to: value) diff --git a/Sources/ParseSwift/Types/QueryConstraint.swift b/Sources/ParseSwift/Types/QueryConstraint.swift index fde656542..aaee738d9 100644 --- a/Sources/ParseSwift/Types/QueryConstraint.swift +++ b/Sources/ParseSwift/Types/QueryConstraint.swift @@ -167,7 +167,7 @@ public func equalTo (key: String, /** Add a constraint that requires that a key is equal to a `ParseObject`. - parameter key: The key that the value is stored in. - - parameter value: The `ParseObject` to compare. + - parameter object: The `ParseObject` to compare. - returns: The same instance of `QueryConstraint` as the receiver. - throws: An error of type `ParseError`. - warning: See `equalTo` for more information. @@ -175,8 +175,8 @@ public func equalTo (key: String, where isUsingEqualQueryConstraint == true is known not to work for LiveQuery on Parse Servers <= 5.0.0. */ -public func == (key: String, value: T) throws -> QueryConstraint where T: ParseObject { - try equalTo(key: key, value: value) +public func == (key: String, object: T) throws -> QueryConstraint where T: ParseObject { + try equalTo(key: key, object: object) } /** @@ -192,14 +192,35 @@ public func == (key: String, value: T) throws -> QueryConstraint where T: Par - warning: `usingEqComparator == true` is known not to work for LiveQueries on Parse Servers <= 5.0.0. */ +@available(*, deprecated, message: "Replace \"value\" with \"object\"") public func equalTo (key: String, value: T, //swiftlint:disable:next line_length usingEqComparator: Bool = configuration.isUsingEqualQueryConstraint) throws -> QueryConstraint where T: ParseObject { + try equalTo(key: key, object: value, usingEqComparator: usingEqComparator) +} + +/** + Add a constraint that requires that a key is equal to a `ParseObject`. + - parameter key: The key that the value is stored in. + - parameter object: The `ParseObject` to compare. + - parameter usingEqComparator: Set to **true** to use **$eq** comparater, + allowing for multiple `QueryConstraint`'s to be used on a single **key**. + Setting to *false* may override any `QueryConstraint`'s on the same **key**. + Defaults to `ParseSwift.configuration.isUsingEqualQueryConstraint`. + - returns: The same instance of `QueryConstraint` as the receiver. + - throws: An error of type `ParseError`. + - warning: `usingEqComparator == true` is known not to work for LiveQueries + on Parse Servers <= 5.0.0. + */ +public func equalTo (key: String, + object: T, + //swiftlint:disable:next line_length + usingEqComparator: Bool = configuration.isUsingEqualQueryConstraint) throws -> QueryConstraint where T: ParseObject { if !usingEqComparator { - return try QueryConstraint(key: key, value: value.toPointer()) + return try QueryConstraint(key: key, value: object.toPointer()) } else { - return try QueryConstraint(key: key, value: value.toPointer(), comparator: .equalTo) + return try QueryConstraint(key: key, value: object.toPointer(), comparator: .equalTo) } } @@ -216,11 +237,11 @@ public func != (key: String, value: T) -> QueryConstraint where T: Codable { /** Add a constraint that requires that a key is not equal to a `ParseObject`. - parameter key: The key that the value is stored in. - - parameter value: The `ParseObject` to compare. + - parameter object: The `ParseObject` to compare. - returns: The same instance of `QueryConstraint` as the receiver. */ -public func != (key: String, value: T) throws -> QueryConstraint where T: ParseObject { - try QueryConstraint(key: key, value: value.toPointer(), comparator: .notEqualTo) +public func != (key: String, object: T) throws -> QueryConstraint where T: ParseObject { + try QueryConstraint(key: key, value: object.toPointer(), comparator: .notEqualTo) } internal struct InQuery: Codable where T: ParseObject { @@ -321,19 +342,19 @@ public func and (queries: Query...) -> QueryConstraint where T: ParseObjec } /** - Add a constraint that requires that a key's value matches a `Query` constraint. - - warning: This only works where the key's values are `ParseObject`s or arrays of `ParseObject`s. + Add a constraint that requires that a key's value matches a `Query`. + - warning: This only works when the key's values are `ParseObject`s or arrays of `ParseObject`s. - parameter key: The key that the value is stored in. - parameter query: The query the value should match. - returns: The same instance of `QueryConstraint` as the receiver. */ -public func == (key: String, value: Query) -> QueryConstraint { - QueryConstraint(key: key, value: InQuery(query: value), comparator: .inQuery) +public func == (key: String, query: Query) -> QueryConstraint { + QueryConstraint(key: key, value: InQuery(query: query), comparator: .inQuery) } /** - Add a constraint that requires that a key's value do not match a `Query` constraint. - - warning: This only works where the key's values are `ParseObject`s or arrays of `ParseObject`s. + Add a constraint that requires that a key's value do not match a `Query`. + - warning: This only works when the key's values are `ParseObject`s or arrays of `ParseObject`s. - parameter key: The key that the value is stored in. - parameter query: The query the value should not match. - returns: The same instance of `QueryConstraint` as the receiver.