FuelLabs / fuel-indexer

πŸ—ƒ The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
https://docs.fuel.network/docs/indexer/
140 stars 66 forks source link

Add support for `.delete()` in `Entity` #1511

Closed ra0x3 closed 7 months ago

ra0x3 commented 7 months ago

.delete()

extern crate alloc;
use fuel_indexer_utils::prelude::*;

#[indexer(manifest = "indexer.manifest.yaml")]
mod indexer_mod {
    fn do_a_thing(e: Event) {
       // Using .delete() on a single instance
       let item = Event::find(Event::field().eq(e.field)).unwrap();
       item.delete();
    }
}

::delete()

extern crate alloc;
use fuel_indexer_utils::prelude::*;

#[indexer(manifest = "indexer.manifest.yaml")]
mod indexer_mod {
    fn do_a_thing(e: Event) {
       // Using ::delete() for all items matching a given query
       Event::delete(Event::field().eq(e.field).and(Event::another_field().eq(e.another_field))).unwrap();
    }
}
deekerno commented 7 months ago

@ra0x3, I'm of the opinion that allowing for record deletion inside of the handler code could lead to a couple of unforeseen issues:

ra0x3 commented 7 months ago

Thanks @deekerno

deekerno commented 7 months ago

Heard. I guess that's more data for the "education gap" that we've been discussing. πŸ˜