go-bongo/bongo

How do I attach afterSave hook?

genxstylez opened this issue · 1 comments

Can you give me a simple example?

Thanks

Strange that nobody has answered this question yet. Your document must comply with the AfterSaveHook interface (declared in collection.go). It means that you should only add AfterSave(*Collection) method, something like this:

type Person struct {
        // ... same as in example
}

func (doc *Person) AfterSave(c *bongo.Collection) error {
        // do something
        return nil
}