Goto Chapter: Top 1 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

1 ArangoDB
 1.1 Examples
 1.2 Global variables
 1.3 GAP categories
 1.4 Constructors
 1.5 Query operations

1 ArangoDB

1.1 Examples

gap> db := AttachAnArangoDatabase( );
[object ArangoDatabase "example"]
gap> db._isSystem();
false
gap> db._name();
"example"
gap> db._drop( "test" );
true
gap> coll := db._create( "test" );
[ArangoCollection "test"]
gap> db.test;
[ArangoCollection "test"]
gap> coll.count();
0
gap> db.test.count();
0
gap> InsertIntoDatabase( rec( _key := "1", TP := "x-y" ), coll );
[ArangoDocument]
gap> coll.count();
1
gap> db._truncate( coll );
true
gap> coll.count();
0
gap> coll.save( rec( _key := "1", TP := "x-y" ) );
[ArangoDocument]
gap> coll.count();
1
gap> db._truncate( coll );
true
gap> coll.count();
0
gap> coll.save( rec( _key := "1", TP := "x-y" ) );
[ArangoDocument]
gap> coll.save( rec( _key := "2", TP := "x*y" ) );
[ArangoDocument]
gap> InsertIntoDatabase( rec( _key := "3", TP := "x+2*y" ), coll );
[ArangoDocument]
gap> coll.count();
3
gap> UpdateDatabase( "3", rec( TP := "x+y", a := 42, b := " a\nb " ), coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> UpdateDatabase( "3", rec( c := rec( d := [ 1, "e" ] ) ), coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> coll.ensureIndex(rec( type := "hash", fields := [ "TP" ] ));
[ArangoDocument]
gap> t := rec( query := "FOR e IN test SORT e._key RETURN e", count := true );;
gap> t := db._createStatement( t );
[ArangoStatement in [object ArangoDatabase "example"]]
gap> c := t.execute();
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> c.count();
3
gap> a := c.toArray();
[ArangoArray of length 3]
gap> Length( a );
3
gap> Length( List( a ) );
3
gap> a[1].TP;
"x-y"
gap> a[2].TP;
"x*y"
gap> a[3].TP;
"x+y"
gap> a[3].a;
42
gap> a[3].b;
" a\nb "
gap> IsBound( a[3].c );
true
gap> a[3].c;
rec( d := [ 1, "e" ] )
gap> c := t.execute();
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> i := Iterator( c );
<iterator>
gap> d1 := NextIterator( i );
[ArangoDocument]
gap> d1.TP;
"x-y"
gap> d2 := NextIterator( i );
[ArangoDocument]
gap> d2.TP;
"x*y"
gap> d3 := NextIterator( i );
[ArangoDocument]
gap> d3.TP;
"x+y"
gap> d3.a;
42
gap> d3.b;
" a\nb "
gap> IsBound( d3.c );
true
gap> d3.c;
rec( d := [ 1, "e" ] )
gap> r3 := DatabaseDocumentToRecord( d3 );;
gap> IsRecord( r3 );
true
gap> Set( NamesOfComponents( r3 ) );
[ "TP", "_id", "_key", "_rev", "a", "b", "c" ]
gap> [ r3._id, r3._key, r3.TP, r3.a, r3.b, r3.c ];
[ "test/3", "3", "x+y", 42, " a\nb ", rec( d := [ 1, "e" ] ) ]
gap> UpdateDatabase( "1", rec( TP := "x+y" ), coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> q := QueryDatabase( rec( TP := "x+y" ), ["_key","TP","a","b","c"], coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> a := q.toArray();
[ArangoArray of length 2]
gap> Set( List( a, DatabaseDocumentToRecord ) );
[ rec( TP := "x+y", _key := "1", a := fail, b := fail, c := fail ), 
  rec( TP := "x+y", _key := "3", a := 42, b := " a\nb ", 
      c := rec( d := [ 1, "e" ] ) ) ]
gap> RemoveFromDatabase( "2", coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> coll.count();
2
gap> db._exists( "test/1" );
true
gap> IsRecord( coll.exists( "1" ) );
true
gap> db._exists( "test/2" );
false
gap> coll.exists( "2" );
false
gap> db._exists( "test/3" );
true
gap> db._document( "test/3" );
[ArangoDocument]
gap> coll.document( "3" );
[ArangoDocument]
gap> q := QueryDatabase( rec( TP := "x+y" ), coll );
[ArangoQueryCursor in [object ArangoDatabase "example"]]
gap> q.count();
2
gap> MarkFirstDocument( rec( TP := "x+y" ), rec( TP_lock := "me1" ), coll );
[ArangoDocument]
gap> MarkFirstDocument( rec( TP := "x+y" ), rec( TP_lock := "me2" ), coll );
[ArangoDocument]

1.2 Global variables

1.2-1 HOMALG_IO_ArangoShell
‣ HOMALG_IO_ArangoShell( global variable )

1.2-2 InfoArangoDB
‣ InfoArangoDB( info class )

1.3 GAP categories

1.3-1 IsArangoDatabase
‣ IsArangoDatabase( arg )( filter )

Returns: true or false

The GAP category of Arango databases.

1.3-2 IsDatabaseCollection
‣ IsDatabaseCollection( arg )( filter )

Returns: true or false

The GAP category of collections in a database.

1.3-3 IsDatabaseStatement
‣ IsDatabaseStatement( arg )( filter )

Returns: true or false

The GAP category of database statements.

1.3-4 IsDatabaseCursor
‣ IsDatabaseCursor( arg )( filter )

Returns: true or false

The GAP category of database cursors.

1.3-5 IsDatabaseArray
‣ IsDatabaseArray( arg )( filter )

Returns: true or false

The GAP category of database arrays.

1.3-6 IsDatabaseDocument
‣ IsDatabaseDocument( arg )( filter )

Returns: true or false

The GAP category of documents in a database collecton.

1.4 Constructors

1.4-1 AttachAnArangoDatabase
‣ AttachAnArangoDatabase( opts )( function )

Returns: an Arango database

Attach an existing database by invoking arangosh with an optional list of options opts which if not provided defaults to HOMALG_IO_ArangoShell.options.

1.5 Query operations

1.5-1 InsertIntoDatabase
‣ InsertIntoDatabase( keys_values_rec, collection )( operation )
‣ InsertIntoDatabase( keys_values_rec, collection )( operation )

Returns: none

Insert a new document into collection with keys and values given by the record keys_values_rec.

1.5-2 UpdateDatabase
‣ UpdateDatabase( query_rec, str, collection )( operation )
‣ UpdateDatabase( query_rec, keys_values_rec, collection )( operation )
‣ UpdateDatabase( id, keys_values_rec, collection )( operation )

Returns: a database cursor

Update the document(s) filtered by the record query_rec or with the identifier string id in collection using the keys-values record keys_values_rec of which str = GapToJsonString( keys_values_rec ). The option to directly provide a string str is for experts.

1.5-3 RemoveFromDatabase
‣ RemoveFromDatabase( id, collection )( operation )

Returns: none

Remove the document with identifier id from collection.

1.5-4 RemoveKeyFromCollection
‣ RemoveKeyFromCollection( key_name, query_rec, collection )( operation )
‣ RemoveKeyFromCollection( key_name, collection )( operation )

Returns: a database cursor

Remove the key with the name key_name from the documents in the collection coll satisfying the query record query_rec. If not specified query_rec defaults to the empty record.

1.5-5 QueryDatabase
‣ QueryDatabase( collection )( operation )
‣ QueryDatabase( query_str, collection )( operation )
‣ QueryDatabase( query_rec, collection )( operation )
‣ QueryDatabase( query_str, result, collection )( operation )
‣ QueryDatabase( query_rec, result, collection )( operation )

Returns: a database cursor

Return the cursor defined by the query within collection defined by the following options:

1.5-6 MarkFirstNDocuments
‣ MarkFirstNDocuments( n, query_rec, mark_rec, collection )( operation )

Returns: a database array, false, or fail

Mark by the entries of mark_rec the first n (or less) documents in collection (1) satisfying query_rec and (2) not containing values for the keys in mark_rec and return them in a database array. If (1) fails return [ false ]. If (1) and (2) fail return [ fail ]. The operation is atomic.

1.5-7 MarkFirstDocument
‣ MarkFirstDocument( query_rec, mark_rec, collection )( operation )

Returns: a database document, false, or fail

Returns MarkFirstNDocuments( 1, query_rec, mark_rec, collection )[1], or false, or fail

1.5-8 Iterator
‣ Iterator( cursor )( operation )
‣ Iterator( array )( operation )

Returns: an iterator

Convert database cursor into a GAP iterator.

Convert database array into a GAP iterator.

1.5-9 ListOp
‣ ListOp( array )( operation )
‣ ListOp( cursor )( operation )

Returns: a list

Convert database array into a GAP list of database documents.

Use as List(array).

Convert database cursor into a GAP list of database documents.

Use as List(cursor).

1.5-10 ListOp
‣ ListOp( array, f )( operation )
‣ ListOp( cursor, f )( operation )

Returns: a list

Convert database array into a GAP list of database documents by applying the function f.

Use as List(array, f).

Convert database cursor into a GAP list of database documents by applying the function f.

Use as List(cursor, f).

1.5-11 SumOp
‣ SumOp( cursor, f )( operation )
‣ SumOp( array, f )( operation )

Returns: a list

Convert database cursor into a GAP list of database documents by applying the function f.

Use as Sum(cursor, f).

Convert database array into a GAP list of database documents by applying the function f.

Use as Sum(array, f).

1.5-12 DatabaseDocumentToRecord
‣ DatabaseDocumentToRecord( document )( operation )

Returns: a record

Convert document into a GAP record.

1.5-13 DisplayInArangoSh
‣ DisplayInArangoSh( object )( operation )

Returns: none

Display in arangosh, the Arango shell.

1.5-14 ArangoImport
‣ ArangoImport( filename, collection )( operation )

Returns: none

Import file named filename to collection. Accepted options:

See (https://docs.arangodb.com/3.2/Manual/Administration/Arangoimp.html).

1.5-15 DocumentsWithDeadLocks
‣ DocumentsWithDeadLocks( json_key, collection )( operation )

Returns: a list of documents

Check collection for documents d with existing d.(json_key_lock) created on this server but with no GAP process with PID=d.(json_key_lock).PID. Here json_key_lock := Concatenation( json_key, "_lock" ).

1.5-16 RemoveDeadLocksFromDocuments
‣ RemoveDeadLocksFromDocuments( json_key, collection )( operation )

Returns: a list of documents

Remove the deadlocks in all documents found by DocumentsWithDeadLocks( json_key, collection ).

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 Ind

generated by GAPDoc2HTML