ArangoDB Dart Driver

The dart driver for ArangoDB the native multi-model database

Index

Quick Reference

DatabaseCollectionDocumentIndex
createDatabasecreatereplaceensureIndex
existsloadupdateensureHashIndex
versionunloadbulkUpdateensureSkipList
listDatabasessetPropertiesremoveensureGeoIndex
listUserDatabasesrenamelistensureFulltextIndex
dropDatabaserotatesaveensurePersistentIndex
truncatetruncateindex
querydropindexes
rawQueryensureExistsdropIndex
import
CursorSimple QueryTransaction
countallbeginTransaction
alllistlistTransactions
nextanyexecuteTransaction
hasNextbyExampleexists
nextBatchfirstExampleget
eachremoveByExamplecommit
everyreplaceByExampleabort
someupdateByExamplerun
maplookupByKeys
reduceremoveByKeys
kill

Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

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]
}

Run query:

import 'package:arango/arango.dart';

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

  final cursor = await db.rawQuery('FOR todo IN todos RETURN todo.title');
  final data = await cursor.all();
  print(data);

  // or with the fluent query builder
  final result = await db
      .query()
      .line('FOR todo IN todos')
      .line('RETURN todo.title')
      .toList();
  print(result);
}

AQL

The ArangoDB Query Language (AQL) can be used to retrieve and modify data that are stored in ArangoDB.

To learn more about AQL, please refer to https://www.arangodb.com/docs/stable/aql/

Features and bugs

Please file feature requests and bugs at the issue tracker.

Todo

AnalyzerView
existsarangoSearchView
getlistViews
createviews
drop
listAnalyzers
analyzers
analyzer

Libraries

arango
ArangoDB Dart driver [...]