func SmallDB() *Database { db := New(SmallConfig()) defer db.Close() makeIndex(db, "created", 0) addIndex(db, indexes.NewSortedInts("age")) return db }
func makeIndex(db *Database, name string, ids ...int) indexes.Index { index := indexes.NewSortedInts(name) for _, id := range ids { index.SetInt(key.Type(id), id) } if db != nil { addIndex(db, index) } return index }
func (db *Database) getOrCreateSortedIntIndex(indexName string) indexes.WithIntScores { return db.getOrCreateIndex(indexName, func() indexes.Index { return indexes.NewSortedInts(indexName) }).(indexes.WithIntScores) }