save method

  1. @override
Future<bool> save({
  1. bool autoReshare = true,
  2. ObjectLifeCycleOptions? options,
})

Saves the json representation of AtCollectionModel to the secondary server of a atSign. save calls toJson method to get the json representation of a AtCollectionModel.

If autoReshare is set to true, then the Object will not only be saved but also be shared with the atSigns with whom it was previously shared.

If autoReshare is set to false, then the object is not shared till the autoReshare method is called.

Pass options to control lifecycle of the object.

Usage

class Phone extends AtCollectionModel {
 // Implementation
}

Creating phone objects without options

Phone personalPhone = await Phone('personal phone').save();
Phone officePhone = await Phone('office phone').save();

Creating a phone objects with options

phone object that lives only for 24 hrs.

Phone temporaryPhone = await Phone('temporary phone').save(options : ObjectLifeCycleOptions(timeToLive : Duration(hours : 24)));

By default the value shared is cached on the recipient, if this has to changed then set objectLifeCycleOptions cacheValueOnRecipient to fasle. By default when the object is deleted then the cached values on the recipients are deleted. if this needs to be changed set objectLifeCycleOptions.cascadeDelete to false.

Returns a true if save is successful else returns a false. If fine grained information on individual operations that happens within save is desired then use streams.save

Implementation

@override
Future<bool> save(
    {bool autoReshare = true, ObjectLifeCycleOptions? options}) async {
  return _atCollectionModelOperations.save(
      autoReshare: autoReshare, options: options);
}