// NewAdapter is the constructor for Adapter. If database name is not provided
// in the Mongo URL, 'casbin' will be used as database name.
NewAdapter is the constructor for Adapter. If database name is not provided
in the Mongo URL, 'casbin' will be used as database name.
// NewAdapter is the constructor for Adapter . If database name is not provided // in the Mongo URL ' casbin ' will be used as database name .
func NewAdapter(url string, timeout ...interface{}) (persist.Adapter, error) {
	if !strings.HasPrefix(url, "mongodb+srv://") && !strings.HasPrefix(url, "mongodb://") {
		url = fmt.Sprint("mongodb://" + url)
	}
	clientOption := options.Client().ApplyURI(url)
	u, err := neturl.Parse(url)
	if err != nil {
		return nil, err
	}
	var databaseName string
	if u.Path != "" {
		databaseName = u.Path[1:]
	} else {
		databaseName = "casbin_rule"
	}
	return NewAdapterWithClientOption(clientOption, databaseName, timeout...)
}
func NewAdapter ( url string , timeout ... interface { } ) ( persist . Adapter , error ) { if ! strings . HasPrefix ( url , " " ) && ! strings . HasPrefix ( url , " " ) { url = fmt . Sprint ( " " + url ) } clientOption := options . Client ( ) . ApplyURI ( url ) u , err := neturl . Parse ( url ) if err != nil { return nil , err } var databaseName string if u . Path != " " { databaseName = u . Path [ 1 : ] } else { databaseName = " " } return NewAdapterWithClientOption ( clientOption , databaseName , timeout ... ) }
NewAdapter is the constructor for Adapter.
NewAdapter is the constructor for Adapter .