orchbase_dart_sdk 0.25.4 copy "orchbase_dart_sdk: ^0.25.4" to clipboard
orchbase_dart_sdk: ^0.25.4 copied to clipboard

Multi-platform Dart SDK for the OrchBase PostgreSQL backend-as-a-service.

example/example.dart

// ignore_for_file: unnecessary_lambdas

import "dart:async";

import "package:orchbase_dart_sdk/orchbase.dart";

void main() {
  final ob = OrchBase("http://127.0.0.1:8090");

  // fetch a paginated list with "example" records
  ob
      .collection("example")
      .getList(page: 1, perPage: 10)
      .then((result) {
        // success...
        print("Result: $result");
      })
      .catchError((dynamic error) {
        // error...
        print("Error: $error");
      });

  // listen to realtime connect/reconnect events
  ob.realtime.subscribe("OB_CONNECT", (e) {
    print("Connected: $e");
  });

  // subscribe to realtime changes in the "example" collection
  ob.collection("example").subscribe("*", (e) {
    print(e.action); // create, update, delete
    print(e.record); // the changed record
  });

  // unsubsribe from all "example" realtime subscriptions after 10 seconds
  Timer(const Duration(seconds: 10), () {
    ob.realtime.unsubscribe(); // unsubscribe from all realtime events
  });
}
0
likes
160
points
129
downloads

Documentation

API reference

Publisher

verified publisheropenqrm.dev

Weekly Downloads

Multi-platform Dart SDK for the OrchBase PostgreSQL backend-as-a-service.

Homepage

Topics

#backend #postgres #baas #realtime #sdk

License

MIT (license)

Dependencies

http, json_annotation

More

Packages that depend on orchbase_dart_sdk