//FindAllFromFilter returns a mongo.Cursor that can be iterated over
//In order to return all the documents you need to have an empty filter
FindAllFromFilter returns a mongo.Cursor that can be iterated over
In order to return all the documents you need to have an empty filter
// FindAllFromFilter returns a mongo . Cursor that can be iterated over // In order to return all the documents you need to have an empty filter
func (db *DB) FindAllFromFilter(collectionName string, filter bson.M) (*mongo.Cursor, error) {
	collection := db.Client.Database(db.DatabaseName).Collection(collectionName)
	cursor, err := collection.Find(db.BasicContext, filter)
	if err != nil {
		return nil, err
	}
	return cursor, nil
}
func ( db * DB ) FindAllFromFilter ( collectionName string , filter bson . M ) ( * mongo . Cursor , error ) { collection := db . Client . Database ( db . DatabaseName ) . Collection ( collectionName ) cursor , err := collection . Find ( db . BasicContext , filter ) if err != nil { return nil , err } return cursor , nil }
FindAllFromFilter returns a mongo.Cursor that can be iterated over
In order to return all the documents you need to have an empty filter
FindAllFromFilter returns a mongo . Cursor that can be iterated over In order to return all the documents you need to have an empty filter
// Get a list of all returned documents and print them out. //See the mongo.Cursor documentation for more examples of using cursors. // var results []bson.M if err = cursor.All(context.TODO(), &results); // err != nil { log.Fatal(err) } //for _, result := range results { fmt.Println(result) }