function writeOp(name, args, documents) {
  checkArgs(name, args)
  let isBatch = true
  let wrappedDocs = documents
  if (!Array.isArray(documents)) {
    // Wrap in an array if we need to
    wrappedDocs = [ documents ]
    isBatch = false
  } else if (documents.length === 0) {
    // Don't bother sending no-ops to the server
    return Observable.empty()
  }
  const options = Object.assign(
    {}, this._query, { data: serialize(wrappedDocs) })
  let observable = this._sendRequest(name, options)
  if (isBatch) {
    // If this is a batch writeOp, each document may succeed or fail
    // individually.
    observable = observable.map(
      resp => resp.error ? new Error(resp.error) : resp)
  } else {
    // If this is a single writeOp, the entire operation should fail
    // if any fails.
    const _prevOb = observable
    observable = Observable.create(subscriber => {
      _prevOb.subscribe({
        next(resp) {
          if (resp.error) {
            // TODO: handle error ids when we get them
            subscriber.error(new Error(resp.error))
          } else {
            subscriber.next(resp)
          }
        },
        error(err) { subscriber.error(err) },
        complete() { subscriber.complete() },
      })
    })
  }
  if (!this._lazyWrites) {
    // Need to buffer response since this becomes a hot observable and
    // when we subscribe matters
    observable = observable.publishReplay().refCount()
    observable.subscribe()
  }
  return observable
}
@this Collection
 Implements writeOps for the Collection class