storm icon indicating copy to clipboard operation
storm copied to clipboard

Is there a way to get the next sequence before saving an object?

Open mivinci opened this issue 4 years ago • 0 comments

I have a struct as follows

type struct App {
    ID   int `storm:"increment"`
    Uid  int `storm:"index"`
    Key string
}

and I want to give a value to Key before saving each instance, the value is calculated with ID and Uid. So is there a way to get the next sequence before saving an object like the way you use BoltDB?

Yes, I can make this done by updating the key after saving the object, but that's several more lines of code and I'm afraid of two IO operations for every single creation of an object.

mivinci avatar Feb 09 '21 08:02 mivinci