...

Source file src/github.com/go-kivik/kivik/v4/kiviktest/client/replicate_js.go

Documentation: github.com/go-kivik/kivik/v4/kiviktest/client

     1  // Licensed under the Apache License, Version 2.0 (the "License"); you may not
     2  // use this file except in compliance with the License. You may obtain a copy of
     3  // the License at
     4  //
     5  //  http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Unless required by applicable law or agreed to in writing, software
     8  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     9  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    10  // License for the specific language governing permissions and limitations under
    11  // the License.
    12  
    13  //go:build js
    14  
    15  package client
    16  
    17  import (
    18  	"github.com/gopherjs/gopherjs/js"
    19  
    20  	kivik "github.com/go-kivik/kivik/v4"
    21  	"github.com/go-kivik/kivik/v4/kiviktest/kt"
    22  )
    23  
    24  type multiOptions []kivik.Option
    25  
    26  func (mo multiOptions) Apply(target interface{}) {
    27  	for _, o := range mo {
    28  		o.Apply(target)
    29  	}
    30  }
    31  
    32  func replicationOptions(ctx *kt.Context, client *kivik.Client, target, source, repID string, in kivik.Option) kivik.Option {
    33  	if ctx.String("mode") != "pouchdb" {
    34  		return multiOptions{kivik.Param("_id", repID), in}
    35  	}
    36  	return multiOptions{
    37  		kivik.Param("source", js.Global.Get("PouchDB").New(source)),
    38  		kivik.Param("target", js.Global.Get("PouchDB").New(target)),
    39  		in,
    40  	}
    41  }
    42  

View as plain text