예제 #1
0
func SmallDB() *Database {
	db := New(SmallConfig())
	defer db.Close()
	makeIndex(db, "created", 0)
	addIndex(db, indexes.NewSortedInts("age"))
	return db
}
예제 #2
0
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
}
예제 #3
0
파일: database.go 프로젝트: Wexcode/nabu
func (db *Database) getOrCreateSortedIntIndex(indexName string) indexes.WithIntScores {
	return db.getOrCreateIndex(indexName, func() indexes.Index {
		return indexes.NewSortedInts(indexName)
	}).(indexes.WithIntScores)
}