arango library

ArangoDB Dart driver

Usage

A simple todo example:

import 'package:arango/arango.dart';

void main() async {
  final db = ArangoDatabase('http://localhost:8529');
  db.useBasicAuth('root', 'YOUR-PASSWORD');

  await db.collection('todos').ensureExists();
  await db.collection('todos').ensureTTLIndex(['expiresAt']);
  await db.collection('todos').ensureFulltextIndex(['content']);

  await db.collection('todos').save({'content': 'Go shopping'});
  await db.collection('todos').save({'content': 'Go home'});

  final todos = await db
      .query()
      .line('FOR todo IN todos')
      .line('RETURN todo.content')
      .toList();

  print('todos: $todos');
  // -> todos: [Go shopping, Go home]
}

Transactions:

import 'package:arango/arango.dart';

void main() async {
  final db = ArangoDatabase('http://localhost:8529');
  db.useBasicAuth('root', 'YOUR-PASSWORD');

  await db.collection('accounts').ensureExists();
  await db.collection('accounts').truncate();

  final txn = await db.beginTransaction(write: ['accounts']);
  await txn.run(() => db.collection('accounts').save({'id': '1'}));
  await txn.run(() => db.collection('accounts').save({'id': '2'}));
  await txn.commit();

  final txn2 = await db.beginTransaction(write: ['accounts']);
  await txn2.run(() => db.collection('accounts').save({'id': '3'}));
  await txn2.run(() => db.collection('accounts').save({'id': '4'}));
  await txn2.abort();

  final data = await db
      .query()
      .line('FOR account IN accounts')
      .line('RETURN account.id')
      .toList();

  print('accounts: $data');
  // -> accounts: [1, 2]
}

Classes

ArangoCollection
ArangoCursor
ArangoDatabase
ArangoDocumentCollection
ArangoEdgeCollection
ArangoError
ArangoErrorNum
ArangoHttpError
ArangoQuery
ArangoTransaction
CollectionType
CreateDatabaseUser
ImportType
IndexType
KeyGeneratorType
OnDuplicateType

Constants

messages → const Map<int, String>
const {0 : 'Network Error', 400 : 'Bad Request', 401 : 'Unauthorized', 402 : 'Payment Required', 403 : 'Forbidden', 404 : 'Not Found', 405 : 'Method…
nativeErrorKeys → const Set<String>
const {'fileName', 'lineNumber', 'columnNumber', 'stack', 'description', 'number'}