Exemple #1
0
func SmallDB() *Database {
	db := New(SmallConfig())
	defer db.Close()
	makeIndex(db, "created", 0)
	addIndex(db, indexes.NewSortedInts("age"))
	return db
}
Exemple #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
}
Exemple #3
0
func (db *Database) getOrCreateSortedIntIndex(indexName string) indexes.WithIntScores {
	return db.getOrCreateIndex(indexName, func() indexes.Index {
		return indexes.NewSortedInts(indexName)
	}).(indexes.WithIntScores)
}