saveObjects<T extends VasatModel<T>> method

  1. @override
Future<bool> saveObjects<T extends VasatModel<T>>(
  1. List<T> objects
)
override

Implementation

@override
Future<bool> saveObjects<T extends VasatModel<T>>(List<T> objects) {
  if (db != null) {
    // First get the vasat object name
    var objectName = objects.first.getObjectName();
    var store = stringMapStoreFactory.store(objectName);
    var keys = objects.map((e) => e.id.toString()).toList();
    var values = objects.map((e) => e.toJson()).toList();
    return store.records(keys).put(db!, values, merge: true).then((value) => true);
  } else {
    throw VasatError("DB is null or has not been initializes. Make sure openDatabase() has been called ", status: 5100);
  }
}