fire_api_dart 1.7.4 copy "fire_api_dart: ^1.7.4" to clipboard
fire_api_dart: ^1.7.4 copied to clipboard

An implementation for fire_api for dart servers using googleapis.

fire_api_dart #

fire_api_dart is the Dart server implementation for fire_api.

It provides the shared FirestoreDatabase and FireStorage API on top of Google Cloud Firestore and Storage.

Setup #

Run on Google Cloud or provide service-account credentials.

Useful environment variables for local development:

  1. GCP_PROJECT=<project_id>
  2. GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_key.json>

If you need a custom database name or authenticated client, use GoogleCloudFirestoreDatabase.create(...).

import 'package:fire_api_dart/fire_api_dart.dart';

void main() async {
  await GoogleCloudFirestoreDatabase.create();
  await GoogleCloudFireStorage.create();
}

Notes #

Vector values #

VectorValue is translated automatically in both directions, including nested maps and lists.

await FirestoreDatabase.instance.collection("items").doc("one").set({
  "embedding": const VectorValue(vector: [0.1, 0.2, 0.3]),
});

findNearest(...).get() is supported in this adapter.

fire_api_dart translates VectorValue into Firestore's sentinel map representation and executes nearest-neighbor queries through StructuredQuery.findNearest.

final docs = await FirestoreDatabase.instance
    .collection("items")
    .whereEqual("color", "red")
    .findNearest(
      vectorField: "embedding",
      queryVector: const VectorValue(vector: [0.1, 0.2, 0.3]),
      limit: 5,
      distanceMeasure: VectorDistanceMeasure.euclidean,
      distanceResultField: "vector_distance",
    )
    .get();

Shared collection deletes #

CollectionReference.deleteAll(...) is implemented in the shared fire_api package, so it works here automatically:

await FirestoreDatabase.instance.collection("sessions").deleteAll();

await FirestoreDatabase.instance.collection("sessions").deleteAll(
  only: {"a", "b", "c"},
  batchSize: 50,
);
0
likes
40
points
647
downloads

Publisher

verified publisherarcane.art

Weekly Downloads

An implementation for fire_api for dart servers using googleapis.

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

Dependencies

chunked_stream, fire_api, google_cloud, googleapis, googleapis_auth, http

More

Packages that depend on fire_api_dart