INNER CODE UNIT · Go

baseNewAdapter

apache/casbin-mongodb-adapter · adapter.go:103

func baseNewAdapter(clientOption *options.ClientOptions, databaseName string, collectionName string, timeout ...interface{}) (persist.BatchAdapter, error) {
	a := &adapter{}
	a.filtered = false

	if len(timeout) == 1 {
		a.timeout = timeout[0].(time.Duration)
	} else if len(timeout) > 1 {
		return nil, errors.New("too many arguments")
	} else {
		a.timeout = defaultTimeout
	}

	// Open the DB, create it if not existed.
	err := a.open(clientOption, databaseName, collectionName)
	if err != nil {
		return nil, err
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…