Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mivinci opened this issue Feb 9, 2021 · 0 comments
Open

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

mivinci opened this issue Feb 9, 2021 · 0 comments

Comments

@mivinci
Copy link

mivinci commented Feb 9, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant