getSimpleObject<T extends Object> method

Future<T?> getSimpleObject<T extends Object>(
  1. String objectName, {
  2. VasatFromJsonFactory<T>? factory,
})

Implementation

Future<T?> getSimpleObject<T extends Object>(String objectName, {VasatFromJsonFactory<T>? factory} ) {
  if (db != null) {
    var store = StoreRef.main();
    return store.record( getObjectKey(objectName) ).get(db!).then((value) {
      if(value != null) {
        return (factory != null) ? factory(value) : value as T;
      } else {
        return null;
      }
    });
  } else {
    throw VasatError("DB is null or has not been initializes. Make sure openDatabase() has been called ", status: 5100);
  }

}