@@ -35,43 +35,24 @@ class BatchRequest {
3535 }
3636
3737 func getBody( internalId: String ) -> [ String : Any ] {
38- var body : [ String : Any ] = [ : ]
39-
40- body [ " __internalId " ] = internalId
41-
38+ var body : [ String : Any ] = [ " __internalId " : internalId]
4239 var children : [ ( String , LCObject ) ] = [ ]
43-
44- operationTable? . forEach { ( key, operation) in
45- switch operation. name {
46- case . set:
47- /* If object is newborn, put it in __children field. */
48- if let child = operation. value as? LCObject {
49- if !child. hasObjectId {
50- children. append ( ( key, child) )
51- break
52- }
53- }
54-
55- body [ key] = operation. lconValue
56- default :
40+ self . operationTable? . forEach { ( key, operation) in
41+ if case . set = operation. name,
42+ let child = operation. value as? LCObject ,
43+ !child. hasObjectId {
44+ children. append ( ( key, child) )
45+ } else {
5746 body [ key] = operation. lconValue
5847 }
5948 }
60-
61- if children. count > 0 {
62- var list : [ Any ] = [ ]
63-
64- children. forEach { ( key, child) in
65- list. append ( [
66- " className " : child. actualClassName,
67- " cid " : child. internalId,
68- " key " : key
69- ] )
49+ if !children. isEmpty {
50+ body [ " __children " ] = children. map { ( key, child) -> [ String : String ] in
51+ [ " className " : child. actualClassName,
52+ " cid " : child. internalId,
53+ " key " : key]
7054 }
71-
72- body [ " __children " ] = list
7355 }
74-
7556 return body
7657 }
7758
0 commit comments