Deleting without fetching #113

Closed
opened 2025-12-29 18:23:09 +01:00 by adam · 0 comments
Owner

Originally created by @jaddoescad on GitHub (Dec 17, 2016).

Hi, I'd like to start off by thanking you for this really awesome Library.

I am using this code to delete a user from coredata:

        let friend: Friend = Static.datastack.fetchOne(
            From(Friend),
            Where("id", isEqualTo: "336360503408940")
        )!
        Static.datastack.beginSynchronous { (transaction) -> Void in
            if let projectModel = transaction.fetchOne(From(Friend), Where("id == 336360503408940")) {
                transaction.delete(projectModel)
            }
            transaction.commitAndWait()
        }

However in your documentation, you mention that we can delete without fetching. I am really confused on how to do that. this is the code you provided for us.

let john: MyPersonEntity = // ...
CoreStore.beginAsynchronous { (transaction) -> Void in
    transaction.delete(john)
    transaction.commit()
}

What would go inside the declaration john in order to have the same effect on deleting.

Thank you

Originally created by @jaddoescad on GitHub (Dec 17, 2016). Hi, I'd like to start off by thanking you for this really awesome Library. I am using this code to delete a user from coredata: ``` let friend: Friend = Static.datastack.fetchOne( From(Friend), Where("id", isEqualTo: "336360503408940") )! Static.datastack.beginSynchronous { (transaction) -> Void in if let projectModel = transaction.fetchOne(From(Friend), Where("id == 336360503408940")) { transaction.delete(projectModel) } transaction.commitAndWait() } ``` However in your documentation, you mention that we can delete without fetching. I am really confused on how to do that. this is the code you provided for us. ``` let john: MyPersonEntity = // ... CoreStore.beginAsynchronous { (transaction) -> Void in transaction.delete(john) transaction.commit() } ``` What would go inside the declaration john in order to have the same effect on deleting. Thank you
adam closed this issue 2025-12-29 18:23:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#113