dartbase_admin 0.1.1 copy "dartbase_admin: ^0.1.1" to clipboard
dartbase_admin: ^0.1.1 copied to clipboard

discontinued
outdated

A dart-native implementation of the Firebase Admin SDK to enable administrive tasks to your firebase project.

example/example.dart

import 'package:dartbase_admin/auth/service_account/service_account.dart';
import 'package:dartbase_admin/dartbase.dart';

const projectId = 'Project Settings -> General -> Project ID';

/// Note: Beware of pushing your credentials to source control.
Future main() async {
  /// You can use environment variable look-up to find your service-account.json like so:
  /// (GOOGLE_APPLICATION_CREDENTIALS is the default environment variable we look for.)
  /// ServiceAccount.fromEnvironmentVariable();
  /// or from a file
  /// ServiceAccount.fromFile(filePath);
  /// or directly from a json string
  /// ServiceAccount.fromJson(String);
  await Firebase.initialize(projectId, ServiceAccount.fromJson(r'''
{
      Project Settings -> Service Accounts -> generate new private key
      Paste the json here
}
'''));

  Firestore.initialize(); // Firestore reuses the firebase client

  // Instantiate a reference to a document - this happens offline
  var ref = Firestore.instance.collection('test').document('doc');

  // Subscribe to changes to that document
  ref.stream.listen((document) => print('updated: $document'));

  // Update the document
  await ref.update({'value': 'test'});

  // Get a snapshot of the document
  var document = await ref.get();
  print('snapshot: ${document['value']}');

  print(
      'Sleeping for 30 seconds. You can make changes to test/doc in the UI console');
  await Future.delayed((const Duration(seconds: 30)));
  print('closing the connection');
  await Firestore.instance.close();
}
5
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A dart-native implementation of the Firebase Admin SDK to enable administrive tasks to your firebase project.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

asn1lib, clock, crypto_keys, fixnum, gcloud, googleapis_auth, grpc, http, jose, json_annotation, meta, openid_client, pointycastle, protobuf, x509

More

Packages that depend on dartbase_admin