bulk method

Future bulk(
  1. List<JsonObjectLite> docs, [
  2. bool allOrNothing = false
])

Bulk insert Bulk inserts a list of documents

Implementation

Future<dynamic> bulk(List<jsonobject.JsonObjectLite<dynamic>> docs,
    [bool allOrNothing = false]) {
  var url = bulkdocs;

  if (allOrNothing) {
    url = _setURLParameter(url, 'all_or_nothing', allOrNothing.toString());
  }

  // Create the bulk insertion data structure
  final documentMap = <String, List<jsonobject.JsonObjectLite<dynamic>>>{};
  documentMap['docs'] = docs;
  String docString;
  try {
    docString = json.encode(documentMap);
  } on Exception {
    return _raiseException(WiltException.bulkCantStringify);
  }

  // Must set the content type for a post
  final headers = <String, String>{};
  headers['Content-Type'] = 'application/json';

  url = _conditionUrl(url);
  return _httpRequest(bulkk, url, data: docString, headers: headers);
}