// LoadFilteredPolicy loads matching policy lines from database. If not nil,
// the filter must be a valid MongoDB selector.
LoadFilteredPolicy loads matching policy lines from database. If not nil,
the filter must be a valid MongoDB selector.
// LoadFilteredPolicy loads matching policy lines from database . If not nil // the filter must be a valid MongoDB selector .
func (a *adapter) LoadFilteredPolicy(model model.Model, filter interface{}) error {
	if filter == nil {
		a.filtered = false
		filter = bson.D{{}}
	} else {
		a.filtered = true
	}
	line := CasbinRule{}
	ctx, cancle := context.WithTimeout(context.TODO(), a.timeout)
	defer cancle()
	cursor, err := a.collection.Find(ctx, filter)
	if err != nil {
		return err
	}
	for cursor.Next(ctx) {
		err := cursor.Decode(&line)
		if err != nil {
			return err
		}
		loadPolicyLine(line, model)
	}
	return cursor.Close(ctx)
}
func ( a * adapter ) LoadFilteredPolicy ( model model . Model , filter interface { } ) error { if filter == nil { a . filtered = false filter = bson . D { { } } } else { a . filtered = true } line := CasbinRule { } ctx , cancle := context . WithTimeout ( context . TODO ( ) , a . timeout ) defer cancle ( ) cursor , err := a . collection . Find ( ctx , filter ) if err != nil { return err } for cursor . Next ( ctx ) { err := cursor . Decode ( & line ) if err != nil { return err } loadPolicyLine ( line , model ) } return cursor . Close ( ctx ) }
LoadFilteredPolicy loads matching policy lines from database.
LoadFilteredPolicy loads matching policy lines from database .