darango 0.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • new54

Darango #

A dart API for ArangoDB

This package based on http and ArangoDB API allows to communicate with your ArangoDB database using Dart. I still work on it on my free time but feel free to help (especially on the proper way of coding).

Using #

You first need to create a database and connect to it.

import 'package:darango/darango.dart';

String url = "http://127.0.0.1:8529";
String database_name = "";
String username = "";
String password = "";

Database database = Database(url);
await database.connect(database_name, username, password);

After that you can make CRUD operations on documents.

Collection usersCollection = await database.collection("users");

if(usersCollection != null){
    // Create
    Map<String, dynamic> user = {"lastName":"Toto", "FirstName":"Titi"};
    Document doc = await usersCollection.document().add(user);
    // Read
    doc = await usersCollection.document().get(doc.id);
    // Update
    Map<String, dynamic> user2 = {"_key":doc.key,"_id":doc.id,"_rev":doc.rev,
        "lastName":"Toto","FirstName":"Titi", "email": "toto@gmail.com"};
    doc = await usersCollection.document().update(user2);
    // Delete
    await usersCollection.document().delete(doc.id);
}

You can also make AQL query.

Aql aql = database.aql();
String query = """
    FOR c IN users
    RETURN c
""";

dynamic result = await aql.run(query);
print(result["result"]);

TODO #

  • Transactions
  • Graph
  • CRUD on collections
  • ...

[0.0.9] - 08/08/2019.

  • Correction on update + replace document

[0.0.8] - 08/08/2019.

  • Add function from HTTP API

[0.0.7] - 08/08/2019.

  • Typo correcting

[0.0.6] - 08/08/2019.

  • Document get/delete on key or id

[0.0.5] - 08/08/2019.

  • Same format from arango for _id, _rev, _key

[0.0.4] - 08/08/2019.

  • Document get on key or on id

[0.0.3] - 07/08/2019.

  • Example added

[0.0.1] - 06/08/2019.

  • First realease

example/main.dart

import 'package:flutter/material.dart';
import 'package:darango/darango.dart';

Database database;

Collection usersCollection;

initArangoDB() async {
  database = Database("http://10.0.2.2:8529");
  database.connect("", "", "");
  usersCollection = await database.collection('users');
}

Future<dynamic> getUser(String id) async {
  Document doc = await usersCollection.document().get(id);
  print(doc.data);
  return doc.data;
}

void main() async{
  await initArangoDB();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    getUser("");

    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  darango: ^0.0.9

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:darango/darango.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
91
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:darango/darango.dart with components: io.

Health issues and suggestions

Document public APIs. (-0.60 points)

147 out of 149 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/aql.dart. (-2.96 points)

Analysis of lib/src/aql.dart reported 6 hints, including:

line 7 col 74: Don't explicitly initialize variables to null.

line 10 col 7: DO use curly braces for all flow control structures.

line 12 col 7: DO use curly braces for all flow control structures.

line 23 col 42: Don't explicitly initialize variables to null.

line 26 col 7: DO use curly braces for all flow control structures.

Fix lib/src/document.dart. (-2.96 points)

Analysis of lib/src/document.dart reported 6 hints, including:

line 66 col 27: The value of the local variable 'doc' isn't used.

line 122 col 12: The value of the local variable 'url' isn't used.

line 126 col 27: The value of the local variable 'doc' isn't used.

line 139 col 12: The value of the local variable 'url' isn't used.

line 143 col 27: The value of the local variable 'doc' isn't used.

Fix lib/src/database.dart. (-1.49 points)

Analysis of lib/src/database.dart reported 3 hints:

line 18 col 7: DO use curly braces for all flow control structures.

line 207 col 9: DO use curly braces for all flow control structures.

line 209 col 9: DO use curly braces for all flow control structures.

Fix additional 5 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/src/collection.dart (2 hints)
  • lib/darango.dart (1 hint)
  • lib/src/client.dart (Run dartfmt to format lib/src/client.dart.)
  • lib/src/graph.dart (Run dartfmt to format lib/src/graph.dart.)
  • lib/src/transaction.dart (Run dartfmt to format lib/src/transaction.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6