Skopelos icon indicating copy to clipboard operation
Skopelos copied to clipboard

How to use NSBatchUpdateRequest

Open shardul89 opened this issue 5 years ago • 1 comments

Here is the sample code that I am using:

let dataStore = SkopelosClient.sqliteStack()
dataStore.writeSync({ context in
            
            // Update Records
            let batchRequest = NSBatchUpdateRequest(
                entityName: "User"
            )
            batchRequest.propertiesToUpdate = ["lastname": "T123T"]
            batchRequest.resultType = .updatedObjectsCountResultType
            
            do {
                let result = try? context.execute(batchRequest)
                print("Success")
            } catch {
                print("Error")
            }
            
}).read({ context in
            let users = User.SK_all(context)
            print(users)
})

I am trying to batch update using Skopelos library. But its not printing log Success or Error. Breakpoint is hitting at line let result = try? context.execute(batchRequest) but not moving ahead.

Any help will be appriciated.

shardul89 avatar May 01 '19 09:05 shardul89

@albertodebortoli I am stuck with some urgent issue. Can you please help me here.

shardul89 avatar May 01 '19 09:05 shardul89