add method

Future<bool> add([
  1. List<S> list = const []
])

添加关联对象

Implementation

Future<bool> add([List<S> list = const []]) async {
  if (object.objectId.isEmpty) throw Exception('object objectId is empty');
  if (list.isEmpty) return true;
  var data = await BmobNetHelper.init().put(
    '/1/classes/${object.getBmobTabName()}/${object.objectId}',
    body: {key: createJson(list)},
  );
  if (data != null && data.containsKey('updatedAt')) {
    var _list = list
        .where((e1) => !this.list.any((e2) => e1.objectId == e2.objectId));
    if (_list.isNotEmpty) {
      this.list.addAll(_list);
    }
    return true;
  }
  return false;
}