dorm_firebase_database 1.0.0-alpha.3 copy "dorm_firebase_database: ^1.0.0-alpha.3" to clipboard
dorm_firebase_database: ^1.0.0-alpha.3 copied to clipboard

outdated

A firebase_database database engine for dORM.

dorm_firebase_database #

A dORM's Reference implementation using firebase_database.

Getting started #

Run the following commands in your command prompt:

dart pub add dorm_firebase_database

Using dorm_annotations and dorm_generator, generate your dORM code:

dart run build_runner build

This will create a Dorm class, which you can use to connect to this package.

Usage #

Before accessing any Firebase classes, initialize your app:

void main() async {
  await Firebase.initializeApp();

  // Alternatively, if you're working with non-default apps
  await Firebase.initializeApp(name: 'app-1');

  // You can also pass the `options` parameter with the options generated by FlutterFire
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
}

Create a FirebaseInstance, a class that manages your current Firebase app:

const FirebaseInstance instance = FirebaseInstance();

// Alternatively, if you're working with non-default apps
final FirebaseInstance instance = FirebaseInstance.custom(Firebase.app('app-1'));

// You can also to control the offline management, through `offlineMode`
const FirebaseInstance instance = FirebaseInstance(offlineMode: OfflineMode.include);

With this instance, create a Reference:

final Reference reference = Reference(instance);

// Alternatively, if you want to create your database under 'production/'
final Reference reference = Reference(instance, 'production');

Finally, pass the reference created above to your generated Dorm class:

final Dorm dorm = Dorm(reference);