Skip to content

How to use NSBatchUpdateRequest #32

@shardul89

Description

@shardul89

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions