//ConfigureCollections to be run on startup to check that a number of different Collections exist
//Creates the collections if not already exist
ConfigureCollections to be run on startup to check that a number of different Collections exist
Creates the collections if not already exist
// ConfigureCollections to be run on startup to check that a number of different Collections exist // Creates the collections if not already exist
func (db *DB) ConfigureCollections() error {
	collectionReferences := collections{
		Names: []string{"users", "repositories", "stats", "organisation", "timeSeries"},
		Users: &options.CreateCollectionOptions{},
		Repos: &options.CreateCollectionOptions{},
		Stats: &options.CreateCollectionOptions{},
	}
	for _, name := range collectionReferences.Names {
		exists, err := db.CheckIfCollectionExists(name)
		if err != nil {
			return err
		}
		if !exists {
			fmt.Println("Creating collection: " + name)
			options := options.CreateCollectionOptions{}
			options.SetMaxDocuments(1000)
			options.SetCapped(true)
			options.SetSizeInBytes(100000000)
			if err = db.CreateCollection(name, &options); err != nil {
				return err
			}
		}
	}
	return db.ConfigureTimeSeriesCollections()
}
func ( db * DB ) ConfigureCollections ( ) error { collectionReferences := collections { Names : [ ] string { " " , " " , " " , " " , " " } , Users : & options . CreateCollectionOptions { } , Repos : & options . CreateCollectionOptions { } , Stats : & options . CreateCollectionOptions { } , } for _ , name := range collectionReferences . Names { exists , err := db . CheckIfCollectionExists ( name ) if err != nil { return err } if ! exists { fmt . Println ( " " + name ) options := options . CreateCollectionOptions { } options . SetMaxDocuments ( 1000 ) options . SetCapped ( true ) options . SetSizeInBytes ( 100000000 ) if err = db . CreateCollection ( name , & options ) ; err != nil { return err } } } return db . ConfigureTimeSeriesCollections ( ) }
ConfigureCollections to be run on startup to check that a number of different Collections exist
Creates the collections if not already exist
ConfigureCollections to be run on startup to check that a number of different Collections exist Creates the collections if not already exist