@@ -28,7 +28,7 @@ extension EasyFirestore {
2828 - parameter document: The document with the updated field.
2929 - parameter completion: The completion handler.
3030 */
31- public static func increment< T, U> ( _ path: KeyPath < T , U > , by increase: Int , in document: T , completion: @escaping ( Error ? ) -> Void = { _ in } ) where T: Document , U: AdditiveArithmetic {
31+ public static func increment< T, U> ( _ path: KeyPath < T , U > , by increase: Int = 1 , in document: T , completion: @escaping ( Error ? ) -> Void = { _ in } ) where T: Document , U: AdditiveArithmetic {
3232 let collectionName = String ( describing: T . self)
3333 db. collection ( collectionName) . document ( document. id) . updateData ( [ path. string: FieldValue . increment ( Int64 ( increase) ) ] , completion: completion)
3434 }
@@ -83,30 +83,30 @@ extension EasyFirestore {
8383 db. collection ( collectionName) . document ( document. id) . updateData ( [ path. string: FieldValue . arrayRemove ( items) ] , completion: completion)
8484 }
8585
86- /**
87- Adds a key-value pair to a dictionary in a field in Firestore.
88-
89- - parameter pair: The pair to add to the dictionary value.
90- - parameter path: The path to the document's dictionary field to update.
91- - parameter document: The document to modify.
92- - parameter completion: The completion handler.
93- */
94- public static func add< T, U> ( pair: ( String , U ) , to path: KeyPath < T , Dictionary < String , U > > , in document: T , completion: @escaping ( Error ? ) -> Void = { _ in } ) where T: Document , U: Codable {
95- let collectionName = String ( describing: T . self)
96- db. collection ( collectionName) . document ( document. id) . setData ( [ path. string: [ pair. 0 : pair. 1 ] ] , merge: true , completion: completion)
97- }
98-
99- /**
100- Adds key-value pairs to a dictionary in a field in Firestore.
101-
102- - parameter pairs: The pairs to add to the dictionary value.
103- - parameter path: The path to the document's dictionary field to update.
104- - parameter document: The document to modify.
105- - parameter completion: The completion handler.
106- */
107- public static func add< T, U> ( pairs dict: [ String : U ] , to path: KeyPath < T , Dictionary < String , U > > , in document: T , completion: @escaping ( Error ? ) -> Void = { _ in } ) where T: Document , U: Codable {
108- let collectionName = String ( describing: T . self)
109- db. collection ( collectionName) . document ( document. id) . setData ( dict, merge: true , completion: completion)
110- }
86+ // /**
87+ // Adds a key-value pair to a dictionary in a field in Firestore.
88+ //
89+ // - parameter pair: The pair to add to the dictionary value.
90+ // - parameter path: The path to the document's dictionary field to update.
91+ // - parameter document: The document to modify.
92+ // - parameter completion: The completion handler.
93+ // */
94+ // public static func add<T, U>(pair: (String, U), to path: KeyPath<T, Dictionary<String, U>>, in document: T, completion: @escaping (Error?) -> Void = { _ in }) where T: Document, U: Codable {
95+ // let collectionName = String(describing: T.self)
96+ // db.collection(collectionName).document(document.id).setData([path.string: [pair.0: pair.1]], merge: true, completion: completion)
97+ // }
98+ //
99+ // /**
100+ // Adds key-value pairs to a dictionary in a field in Firestore.
101+ //
102+ // - parameter pairs: The pairs to add to the dictionary value.
103+ // - parameter path: The path to the document's dictionary field to update.
104+ // - parameter document: The document to modify.
105+ // - parameter completion: The completion handler.
106+ // */
107+ // public static func add<T, U>(pairs dict: [String: U], to path: KeyPath<T, Dictionary<String, U>>, in document: T, completion: @escaping (Error?) -> Void = { _ in }) where T: Document, U: Codable {
108+ // let collectionName = String(describing: T.self)
109+ // db.collection(collectionName).document(document.id).setData(dict, merge: true, completion: completion)
110+ // }
111111 }
112112}
0 commit comments