ankhdb 2.0.2 copy "ankhdb: ^2.0.2" to clipboard
ankhdb: ^2.0.2 copied to clipboard

Official AnkhDB Client SDK for Dart and Flutter. Real-time Multi-tenant BaaS.

ankhdb #

pub.dev

The official Dart & Flutter SDK for AnkhDB — a self-hosted, multi-tenant Backend-as-a-Service with Auth, Database, Storage, and Edge Functions.

Installation #

dependencies:
  ankhdb: ^2.0.2

Or: dart pub add ankhdb

Quick Start #

import 'package:ankhdb/ankhdb.dart';

final db = AnkhDB('YOUR_PROJECT_ID', 'YOUR_API_KEY');
// Self-hosted: AnkhDB('proj_...', 'ankh_sec_...', serverUrl: 'http://localhost:5000')

Error Handling #

All errors throw typed exceptions derived from AnkhDBError:

import 'package:ankhdb/ankhdb.dart';

try {
  await db.login('user@example.com', 'wrong');
} on AuthError catch (e) {
  print('Bad credentials: ${e.message}');
} on RateLimitError catch (e) {
  print('Slow down!');
} on AnkhDBError catch (e) {
  print('${e.status}: ${e.message}');
}
Class HTTP Status
AnkhDBError base (all errors)
ValidationError 400
AuthError 401
PermissionError 403
NotFoundError 404
RateLimitError 429
ServerError 5xx

Authentication #

await db.register('user@example.com', 'password');
await db.login('user@example.com', 'password');
final session = await db.getSession();
db.logout();

Database — Query Builder #

db.from(collection) returns a chainable AnkhQuery:

final posts = db.from('posts');

// Basic CRUD
final doc = await posts.insert({'title': 'Hello', 'views': 0});
final all = await posts.select();
final one = await posts.get(doc['id']);
await posts.update(doc['id'], {'views': 1});
await posts.delete(doc['id']);

// Filters
final popular = await db.from('posts')
  .gt('views', 100)
  .eq('status', 'published')
  .select();

// Pagination
final page2 = await db.from('posts').limit(10).offset(10).select();

// Join (embed related collection)
final withComments = await db.from('posts')
  .join('comments', 'postId')  // embed where comments.postId == post.id
  .select();

// Realtime subscription
final stream = db.from('posts').subscribe();
stream.listen((event) {
  print(event['event']); // INSERT / UPDATE / DELETE
  print(event['data']);
});

Storage #

final bytes    = await file.readAsBytes();
final uploaded = await db.storage.upload(bytes, 'photo.jpg');
print(uploaded['url']);

final files = await db.storage.list();
await db.storage.delete(uploaded['id']);

Edge Functions #

final res = await db.functions.invoke('greet', payload: {'name': 'Alice'});
print(res['result']);

License #

MIT © KemetSoft

0
likes
130
points
43
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Official AnkhDB Client SDK for Dart and Flutter. Real-time Multi-tenant BaaS.

Repository (GitHub)

License

MIT (license)

Dependencies

http

More

Packages that depend on ankhdb