Skip to content

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

@mivinci

Description

@mivinci

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.

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