mirror of
https://github.com/asdine/storm.git
synced 2025-10-05 14:56:58 +08:00
Removing AutoIncrement option
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
"github.com/asdine/storm/codec/gob"
|
||||
"github.com/boltdb/bolt"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,7 @@ func ExampleDB_Save() {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
type User struct {
|
||||
ID int `storm:"id"`
|
||||
ID int `storm:"id,increment"`
|
||||
Group string `storm:"index"`
|
||||
Email string `storm:"unique"`
|
||||
Name string
|
||||
@@ -28,7 +29,7 @@ func ExampleDB_Save() {
|
||||
|
||||
// Open takes an optional list of options as the last argument.
|
||||
// AutoIncrement will auto-increment integer IDs without existing values.
|
||||
db, _ := storm.Open(filepath.Join(dir, "storm.db"), storm.AutoIncrement())
|
||||
db, _ := storm.Open(filepath.Join(dir, "storm.db"), storm.Codec(gob.Codec))
|
||||
defer db.Close()
|
||||
|
||||
user := User{
|
||||
@@ -497,7 +498,7 @@ func ExampleNode_RangeScan() {
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int `storm:"id"`
|
||||
ID int `storm:"id,increment"`
|
||||
Group string `storm:"index"`
|
||||
Email string `storm:"unique"`
|
||||
Name string
|
||||
@@ -506,7 +507,7 @@ type User struct {
|
||||
}
|
||||
|
||||
type Account struct {
|
||||
ID int `storm:"id"`
|
||||
ID int `storm:"id,increment"`
|
||||
Amount int64 // amount in cents
|
||||
}
|
||||
|
||||
@@ -517,7 +518,7 @@ type Note struct {
|
||||
|
||||
func prepareDB() (string, *storm.DB) {
|
||||
dir, _ := ioutil.TempDir(os.TempDir(), "storm")
|
||||
db, _ := storm.Open(filepath.Join(dir, "storm.db"), storm.AutoIncrement())
|
||||
db, _ := storm.Open(filepath.Join(dir, "storm.db"))
|
||||
|
||||
for i, name := range []string{"John", "Eric", "Dilbert"} {
|
||||
email := strings.ToLower(name + "@provider.com")
|
||||
|
Reference in New Issue
Block a user