put method

Future<int> put(
  1. String collection,
  2. dynamic json,
  3. [int id]
)

Save json document under specified id or create a new document with new generated id. Returns future holding actual document id.

Implementation

Future<int> put(String collection, dynamic json, [int id]) => Future.sync(() => _mc
    .invokeMethod('put', [
      _handle,
      collection,
      (json is! String) ? convert_lib.jsonEncode(json) : json as String,
      id
    ])
    .catchError(_errorHandler<int>())
    .then((v) => v as int));