### C# Test Class Structure Example Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Demonstrates the naming, namespacing, and file location conventions for test classes, mirroring the library's structure. ```csharp // file: arangodb-net-standard.Test/Stuff/Things/MyClassTest.cs namespace ArangoDBNetStandardTest.Stuff.Things { public class MyClassTest { public async Task MyMethodAsync_ShouldSucceed() { // test code goes here... } } } ``` -------------------------------- ### C# Class Structure Example Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Illustrates the standard C# class structure, including namespace, async method naming, and brace placement. ```csharp // file: arangodb-net-standard/Stuff/Things/MyClass.cs namespace ArangoDBNetStandard.Stuff.Things { public class MyClass { public async Task MyMethodAsync() { // implementation goes here... } } } ``` -------------------------------- ### Error Enum Generation Example Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Example command to run the ErrorEnumGenerator tool, specifying the input file and the output directory for the enum. ```bash ErrorEnumGenerator.exe adb_error_codes.txt C:\repos\arangodb-net-standard\arangodb-net-standard ``` -------------------------------- ### GET /_admin/version Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/project/roadmap.md Returns the server version. ```APIDOC ## GET /_api/version ### Description Return server version. ### Method GET ### Endpoint /_api/version ``` -------------------------------- ### Illustrative API Client Method Signature Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Example of the standard method signature pattern used for REST API calls in the library. ```csharp // This is illustrative, not actually a method in the API apiClient.PostEntity(string pathParam, PostEntityBody body, PostEntityQuery query = null); ``` -------------------------------- ### Set Environment Variables for Tests (Windows) Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Example of setting environment variables for ArangoDB host and port on Windows before running tests. ```bash set ARANGO_PORT=8530 dotnet test ``` -------------------------------- ### Obtain and Set JWT Token for Authentication Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md If you don't have a JWT token, first create an `HttpApiTransport` without authentication. Then, use `AuthApiClient` to get a token by submitting credentials. Finally, set the obtained token on the transport instance using `SetJwtToken`. ```csharp // Create HttpApiTransport with no authentication set var transport = HttpApiTransport.UsingNoAuth( new Uri(arangodbBaseUrl), databaseName); // Create AuthApiClient using the no-auth transport var authClient = new AuthApiClient(transport); // Get JWT token by submitting credentials var jwtTokenResponse = await authClient.GetJwtTokenAsync("username", "password"); // Set token in current transport transport.SetJwtToken(jwtTokenResponse.Jwt); // Use the transport, which will now be authenticated using the JWT token. e.g.: var databaseApi = new DatabaseApiClient(transport); var userDatabasesResponse = await databaseApi.GetUserDatabasesAsync(); ``` -------------------------------- ### GET /_api/user/{user} Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/project/roadmap.md Fetches details for a specific user. ```APIDOC ## GET /_api/user/{user} ### Description Fetch User. ### Method GET ### Endpoint /_api/user/{user} ### Parameters #### Path Parameters - **user** (string) - Required - The username of the user to fetch. ``` -------------------------------- ### Build the Project Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Execute this command to compile the entire project. ```bash dotnet build ``` -------------------------------- ### POST /_api/explain Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/project/roadmap.md Explains an AQL query execution plan. ```APIDOC ## POST /_api/explain ### Description Explain an AQL query. ### Method POST ### Endpoint /_api/explain ``` -------------------------------- ### Create a Database with a User Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Use the _system database to create a new database and a user for it. The HttpApiTransport is disposed after use as it's only needed once. ```csharp // You must use the _system database to create databases using (var systemDbTransport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "_system", "root", "root")) { var systemDb = new DatabaseApiClient(systemDbTransport); // Create a new database with one user. await systemDb.PostDatabaseAsync( new PostDatabaseBody { Name = "arangodb-net-standard", Users = new List { new DatabaseUser { Username = "jlennon", Passwd = "yoko123" } } }); } ``` -------------------------------- ### GET /_api/collection/{collection-name}/checksum Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/project/roadmap.md Returns the checksum for a specific collection. ```APIDOC ## GET /_api/collection/{collection-name}/checksum ### Description Return checksum for the collection. ### Method GET ### Endpoint /_api/collection/{collection-name}/checksum ### Parameters #### Path Parameters - **collection-name** (string) - Required - The name of the collection. ``` -------------------------------- ### Manage graphs, vertices, and edges Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/readme.md Demonstrates creating a graph, adding vertex documents, and linking them with an edge. ```csharp //Example using graphs, vertices and edges string graphName = "SchoolGraph"; string fromClx = "Adults"; string toClx = "Students"; string edgeClx = "Parents"; // Create a new graph await adb.Graph.PostGraphAsync(new PostGraphBody { Name = graphName, EdgeDefinitions = new List { new EdgeDefinition { From = new string[] { fromClx }, To = new string[] { toClx }, Collection = edgeClx } } }); // Create a document in the Adults vertex collection PostDocumentResponse fromResponse = await adb.Document.PostDocumentAsync( fromClx, new { Name = "John Doe" }); // Create a document in the Students vertex collection PostDocumentResponse toResponse = await adb.Document.PostDocumentAsync( toClx, new { Name = "Jimmy Doe" }); // Create the edge Parent edge between the Adult (John Doe) and Child (Jimmy Doe) var response = await adb.Graph.PostEdgeAsync( graphName, edgeClx, new { _from = fromResponse._id, _to = toResponse._id, myKey = "parent1" }, new PostEdgeQuery { ReturnNew = true, WaitForSync = true }); ``` -------------------------------- ### Pack the project for release Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Generates a NuGet package from the project file using the Release configuration. ```bash dotnet pack --configuration Release ./arangodb-net-standard/ArangoDBNetStandard.csproj ``` -------------------------------- ### Create and Manage Graphs in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Demonstrates how to initialize the ArangoDB client, define graph structures with edge collections, and perform administrative tasks like adding collections or deleting graphs. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.GraphApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create a graph with edge definitions var graphResponse = await adb.Graph.PostGraphAsync( new PostGraphBody { Name = "SocialGraph", EdgeDefinitions = new List { new EdgeDefinition { Collection = "friendships", From = new[] { "persons" }, To = new[] { "persons" } }, new EdgeDefinition { Collection = "likes", From = new[] { "persons" }, To = new[] { "posts" } } } }); Console.WriteLine($"Graph created: {graphResponse.Graph.Name}"); // List all graphs var graphs = await adb.Graph.GetGraphsAsync(); foreach (var g in graphs.Graphs) { Console.WriteLine($"Graph: {g._key}"); } // Get graph details var graphDetails = await adb.Graph.GetGraphAsync("SocialGraph"); Console.WriteLine($"Edge collections: {string.Join(", ", graphDetails.Graph.EdgeDefinitions.Select(e => e.Collection))}"); // Add vertex collection await adb.Graph.PostVertexCollectionAsync("SocialGraph", new PostVertexCollectionBody { Collection = "organizations" }); // Add edge definition await adb.Graph.PostEdgeDefinitionAsync("SocialGraph", new PostEdgeDefinitionBody { Collection = "works_at", From = new[] { "persons" }, To = new[] { "organizations" } }); // Delete graph (optionally drop collections) await adb.Graph.DeleteGraphAsync("SocialGraph", new DeleteGraphQuery { DropCollections = false }); ``` -------------------------------- ### Connect to a Database and Create a Collection Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Connect to the newly created database using specific user credentials and create a new collection. For frequent connections, avoid disposing the transport. ```csharp // Use our new database, with basic auth credentials for the user jlennon. var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529"), "arangodb-net-standard", "jlennon", "yoko123"); var adb = new ArangoDBClient(transport); // Create a collection in the database await adb.Collection.PostCollectionAsync( new PostCollectionBody { Name = "MyCollection" // A whole heap of other options exist to define key options, // sharding options, etc }); ``` -------------------------------- ### Execute AQL Queries with ArangoDB Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Shows how to run AQL queries including simple selects, filters, bind variables, and query options. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.CursorApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Simple query var simpleResponse = await adb.Cursor.PostCursorAsync( @"FOR doc IN Products RETURN doc"); foreach (var product in simpleResponse.Result) { Console.WriteLine($"Product: {product.Name}"); } // Query with filter var filteredResponse = await adb.Cursor.PostCursorAsync( @"FOR doc IN Products FILTER doc.Price > 20 RETURN doc"); // Query with bind variables var bindVarsResponse = await adb.Cursor.PostCursorAsync( @"FOR doc IN Products FILTER doc.Category == @category AND doc.Price >= @minPrice SORT doc.Price ASC RETURN doc", bindVars: new Dictionary { ["category"] = "Electronics", ["minPrice"] = 25.00 }); // Query with options (count, batch size, etc.) var optionsResponse = await adb.Cursor.PostCursorAsync( @"FOR doc IN Products RETURN doc", count: true, batchSize: 100, ttl: 60); Console.WriteLine($"Total count: {optionsResponse.Count}"); Console.WriteLine($"Has more: {optionsResponse.HasMore}"); ``` -------------------------------- ### Run Unit Tests Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Use this command to execute all unit tests in the project. ```bash dotnet test ``` -------------------------------- ### Create a New Database Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Use the DatabaseApiClient to create a new database and assign users, requiring access to the _system database. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.DatabaseApi; using ArangoDBNetStandard.DatabaseApi.Models; using ArangoDBNetStandard.Transport.Http; // Connect to _system database to create new databases using (var systemTransport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "_system", "root", "rootPassword")) { var systemDb = new DatabaseApiClient(systemTransport); // Create a new database with users var response = await systemDb.PostDatabaseAsync( new PostDatabaseBody { Name = "newDatabase", Users = new List { new DatabaseUser { Username = "newUser", Passwd = "userPassword", Active = true } } }); Console.WriteLine($"Database created: {response.Result}"); } ``` -------------------------------- ### Initialize ArangoDBClient Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/readme.md Create the main client wrapper using an existing IApiClientTransport instance. ```csharp var adb = new ArangoDBClient(transport); ``` -------------------------------- ### Generate NuGet Package Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Command to create a NuGet package for the library. The output will be in the specified release folder. ```bash dotnet pack --configuration Release .\arangodb-net-standard\ArangoDBNetStandard.csproj ``` -------------------------------- ### Initialize HttpApiTransport with Basic Auth Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Configures the standard HTTP transport using Basic Authentication credentials. ```csharp var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), dbName, "username", "password"); ``` -------------------------------- ### Run an AQL Query Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Execute an AQL query to retrieve documents from a collection. The result is a cursor from which the first document can be accessed. ```csharp // Run AQL query (create a query cursor) var response = await adb.Cursor.PostCursorAsync( @"FOR doc IN MyCollection FILTER doc.ItemNumber == 123456 RETURN doc"); MyClassDocument item = response.Result.First(); ``` -------------------------------- ### Restore NuGet Dependencies Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Run this command to restore all required NuGet packages for the project. ```bash dotnet restore ``` -------------------------------- ### Work with Vertices and Edges in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Shows how to define data models for vertices and edges and perform CRUD operations within a graph context. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.GraphApi.Models; using ArangoDBNetStandard.Transport.Http; public class Person { public string Name { get; set; } public int Age { get; set; } } public class PersonVertex : Person { public string _key { get; set; } public string _id { get; set; } public string _rev { get; set; } } public class Friendship { public string _from { get; set; } public string _to { get; set; } public DateTime Since { get; set; } } var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create vertices var alice = await adb.Graph.PostVertexAsync( "SocialGraph", "persons", new Person { Name = "Alice", Age = 30 }, new PostVertexQuery { ReturnNew = true }); var bob = await adb.Graph.PostVertexAsync( "SocialGraph", "persons", new Person { Name = "Bob", Age = 25 }, new PostVertexQuery { ReturnNew = true }); Console.WriteLine($"Created Alice: {alice.New._id}"); Console.WriteLine($"Created Bob: {bob.New._id}"); // Create edge between vertices var friendship = await adb.Graph.PostEdgeAsync( "SocialGraph", "friendships", new Friendship { _from = alice.New._id, _to = bob.New._id, Since = DateTime.Now }, new PostEdgeQuery { ReturnNew = true }); Console.WriteLine($"Friendship edge: {friendship.New._id}"); // Get vertex var aliceRetrieved = await adb.Graph.GetVertexAsync( "SocialGraph", "persons", alice.New._key); Console.WriteLine($"Retrieved: {aliceRetrieved.Vertex.Name}"); // Update vertex (partial) await adb.Graph.PatchVertexAsync( "SocialGraph", "persons", alice.New._key, new { Age = 31 }); // Replace vertex (full) await adb.Graph.PutVertexAsync( "SocialGraph", "persons", alice.New._key, new Person { Name = "Alice Smith", Age = 31 }); // Delete edge await adb.Graph.DeleteEdgeAsync( "SocialGraph", "friendships", friendship.New._key); // Delete vertex await adb.Graph.DeleteVertexAsync( "SocialGraph", "persons", bob.New._key); ``` -------------------------------- ### Create HttpApiTransport with JWT Authentication Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Use the `UsingJwtAuth` method to create an `HttpApiTransport` instance authenticated with a provided JWT token. Ensure the base path and JWT token are correctly supplied. ```csharp var transport = HttpApiTransport.UsingJwtAuth( new Uri("http://localhost:8529/"), dbName, jwtTokenString); ``` -------------------------------- ### List and Delete Databases with ArangoDBNetStandard Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Retrieves database lists and performs deletion operations. Requires appropriate permissions, such as _system access for administrative tasks. ```csharp using ArangoDBNetStandard.DatabaseApi; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "_system", "root", "rootPassword"); var databaseApi = new DatabaseApiClient(transport); // Get all databases (requires _system access) var allDatabases = await databaseApi.GetDatabasesAsync(); Console.WriteLine($"All databases: {string.Join(", ", allDatabases.Result)}"); // Get databases accessible to current user var userDatabases = await databaseApi.GetUserDatabasesAsync(); Console.WriteLine($"User databases: {string.Join(", ", userDatabases.Result)}"); // Get current database information var currentDbInfo = await databaseApi.GetCurrentDatabaseInfoAsync(); Console.WriteLine($"Current database: {currentDbInfo.Result.Name}"); // Delete a database (requires _system access) var deleteResponse = await databaseApi.DeleteDatabaseAsync("oldDatabase"); Console.WriteLine($"Database deleted: {deleteResponse.Result}"); ``` -------------------------------- ### Perform Server Administration Tasks Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Access server version, engine type, role, logs, and license information. Requires an authenticated ArangoDBClient instance. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.AdminApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "_system", "root", "rootPassword"); var adb = new ArangoDBClient(transport); // Get server version var version = await adb.Admin.GetServerVersionAsync( new GetServerVersionQuery { Details = true }); Console.WriteLine($"Server: {version.Server}"); Console.WriteLine($"Version: {version.Version}"); Console.WriteLine($"License: {version.License}"); // Get database engine type var engine = await adb.Admin.GetServerEngineTypeAsync(); Console.WriteLine($"Engine: {engine.Name}"); // Get server role (for clusters) var role = await adb.Admin.GetServerRoleAsync(); Console.WriteLine($"Server role: {role.Role}"); // Get server logs var logs = await adb.Admin.GetLogsAsync( new GetLogsQuery { Level = LogLevel.Warning, Size = 100 }); foreach (var message in logs.Messages) { Console.WriteLine($"[{message.Level}] {message.Timestamp}: {message.Message}"); } // Get license information (Enterprise only) try { var license = await adb.Admin.GetLicenseAsync(); Console.WriteLine($"License expires: {license.Features?.Expires}"); } catch (ApiErrorException ex) { Console.WriteLine($"License info not available: {ex.Message}"); } ``` -------------------------------- ### Configure Basic Authentication for ArangoDB Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Use HttpApiTransport to establish a connection with Basic Auth credentials. This supports connecting to specific databases or the _system database. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.Transport.Http; // Connect to a specific database using Basic Auth var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); // Create the ArangoDB client var adb = new ArangoDBClient(transport); // Connect to _system database (default when no database specified) var systemTransport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "root", "rootPassword"); ``` -------------------------------- ### Execute Advanced AQL Queries Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Utilizes PostCursorBody for complex query configurations, including profiling and full count statistics. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.CursorApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Use PostCursorBody for advanced options var cursorBody = new PostCursorBody { Query = @"FOR doc IN Products FILTER doc.Category == @category SORT doc.Price LIMIT @limit RETURN doc", BindVars = new Dictionary { ["category"] = "Electronics", ["limit"] = 50 }, Count = true, BatchSize = 25, Options = new PostCursorOptions { FullCount = true, Profile = 1 // Include query profiling } }; var response = await adb.Cursor.PostCursorAsync(cursorBody); Console.WriteLine($"Results: {response.Result.Count}"); Console.WriteLine($"Full count (without LIMIT): {response.Extra?.Stats?.FullCount}"); ``` -------------------------------- ### Instantiate ArangoDBClient Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Create an `ArangoDBClient` instance by passing an `IApiClientTransport` implementation. This client provides access to all individual API client classes. ```csharp var adb = new ArangoDBClient(transport); ``` -------------------------------- ### Obtain and Set JWT Token Dynamically Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/readme.md Initialize a transport without authentication, request a token via AuthApiClient, and update the transport instance. ```csharp // Create HttpApiTransport with no authentication set var transport = HttpApiTransport.UsingNoAuth( new Uri(arangodbBaseUrl), databaseName); // Create AuthApiClient using the no-auth transport var authClient = new AuthApiClient(transport); // Get JWT token by submitting credentials var jwtTokenResponse = await authClient.GetJwtTokenAsync("username", "password"); // Set token in current transport transport.SetJwtToken(jwtTokenResponse.Jwt); // Use the transport, which will now be authenticated using the JWT token. e.g.: var databaseApi = new DatabaseApiClient(transport); var userDatabasesResponse = await databaseApi.GetUserDatabasesAsync(); ``` -------------------------------- ### Create TTL Index in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create a TTL (time-to-live) index to automatically expire documents after a specified period. The index is based on a date field. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.IndexApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create TTL index (time-to-live for automatic document expiration) var ttlIndex = await adb.Index.PostTTLIndexAsync( new PostIndexQuery { CollectionName = "Sessions" }, new PostTTLIndexBody { Fields = new[] { "expiresAt" }, ExpireAfter = 3600, // 1 hour in seconds Name = "idx_session_ttl" }); Console.WriteLine($"TTL index created: {ttlIndex.Id}"); ``` -------------------------------- ### Create Documents in ArangoDB Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Demonstrates inserting single or multiple documents using anonymous types or strongly-typed models. Supports returning the new document state via query parameters. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.DocumentApi.Models; using ArangoDBNetStandard.Transport.Http; // Define your document class public class Product { public string Name { get; set; } public decimal Price { get; set; } public string Category { get; set; } } public class ProductDocument : Product { public string _key { get; set; } public string _id { get; set; } public string _rev { get; set; } } var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create single document with anonymous type var anonResponse = await adb.Document.PostDocumentAsync( "Products", new { Name = "Widget", Price = 29.99, Category = "Electronics" }); Console.WriteLine($"Document key: {anonResponse._key}"); // Create single document with strong type var productResponse = await adb.Document.PostDocumentAsync( "Products", new Product { Name = "Gadget", Price = 49.99, Category = "Electronics" }); // Create document and return the new document var returnNewResponse = await adb.Document.PostDocumentAsync( "Products", new Product { Name = "Gizmo", Price = 19.99, Category = "Tools" }, new PostDocumentsQuery { ReturnNew = true }); Console.WriteLine($"New document name: {returnNewResponse.New.Name}"); // Create multiple documents at once var products = new List { new Product { Name = "Item1", Price = 10.00, Category = "A" }, new Product { Name = "Item2", Price = 20.00, Category = "B" }, new Product { Name = "Item3", Price = 30.00, Category = "C" } }; var batchResponse = await adb.Document.PostDocumentsAsync("Products", products); foreach (var doc in batchResponse) { Console.WriteLine($"Created: {doc._key}"); } ``` -------------------------------- ### Manage Users and Permissions Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create, retrieve, update, and delete users in ArangoDB. Manage database and collection access levels for users. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.UserApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "_system", "root", "rootPassword"); var adb = new ArangoDBClient(transport); // Create new user var userResponse = await adb.User.PostUserAsync( new PostUserBody { User = "newuser", Passwd = "securepassword", Active = true, Extra = new Dictionary { ["email"] = "newuser@example.com", ["department"] = "Engineering" } }); Console.WriteLine($"User created: {userResponse.User}"); // Get all users var users = await adb.User.GetUsersAsync(); foreach (var u in users.Result) { Console.WriteLine($"User: {u.User}, Active: {u.Active}"); } // Set database access level await adb.User.PutDatabaseAccessLevelAsync( "newuser", "myDatabase", new PutAccessLevelBody { Grant = "rw" }); // rw, ro, or none // Set collection access level await adb.User.PutCollectionAccessLevelAsync( "newuser", "myDatabase", "Products", new PutAccessLevelBody { Grant = "ro" }); // Get user's database access level var dbAccess = await adb.User.GetDatabaseAccessLevelAsync("newuser", "myDatabase"); Console.WriteLine($"Database access: {dbAccess.Result}"); // Get user's accessible databases var accessibleDbs = await adb.User.GetAccessibleDatabasesAsync("newuser"); foreach (var db in accessibleDbs.Result) { Console.WriteLine($"Database: {db.Key}, Access: {db.Value}"); } // Update user await adb.User.PatchUserAsync("newuser", new PatchUserBody { Active = false }); // Delete user await adb.User.DeleteUserAsync("newuser"); ``` -------------------------------- ### Create a New Collection using ArangoDBClient Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Access the `Collection` API via the `ArangoDBClient` instance to create a new collection. Provide the collection name in the `PostCollectionBody`. ```csharp // Create a new collection named "TestCollection" var postCollectionResponse = await adb.Collection.PostCollectionAsync( new PostCollectionBody { Name = "TestCollection" }); ``` -------------------------------- ### Push tags to remote Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Pushes the created tags to the upstream repository. ```bash git push upstream --tags ``` -------------------------------- ### Manage Collection Indexes in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt List all indexes for a collection, retrieve details of a specific index, and delete an index. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.IndexApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // List all indexes for a collection var indexes = await adb.Index.GetAllCollectionIndexesAsync( new GetAllCollectionIndexesQuery { CollectionName = "Products" }); foreach (var idx in indexes.Indexes) { Console.WriteLine($"Index: {idx.Name}, Type: {idx.Type}, Fields: {string.Join(", ", idx.Fields ?? Array.Empty())}"); } // Get specific index var indexDetails = await adb.Index.GetIndexAsync("Products/idx_category_price"); // Delete index await adb.Index.DeleteIndexAsync("Products/idx_category_price"); ``` -------------------------------- ### Tag the release commit Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/contributing.md Creates a git tag for the release with the package URL as the message. ```bash git tag -a 1.0.0-alpha01 -m "https://www.nuget.org/packages/ArangoDBNetStandard/1.0.0-alpha01" ``` -------------------------------- ### Create Inverted Index in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create an inverted index for full-text search capabilities. Define fields to be indexed for searching. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.IndexApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create inverted index (for search) var invertedIndex = await adb.Index.PostInvertedIndexAsync( new PostIndexQuery { CollectionName = "Products" }, new PostInvertedIndexBody { Fields = new[] { new InvertedIndexField { Name = "Name" }, new InvertedIndexField { Name = "Description" } }, Name = "idx_search" }); ``` -------------------------------- ### Paginate AQL Query Results Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Handles large result sets by using cursor IDs to fetch subsequent batches of data. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.CursorApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Execute query with small batch size var response = await adb.Cursor.PostCursorAsync( @"FOR doc IN Products RETURN doc", batchSize: 10); var allResults = new List(); allResults.AddRange(response.Result); // Paginate through remaining results while (response.HasMore) { response = await adb.Cursor.PostAdvanceCursorAsync(response.Id); allResults.AddRange(response.Result); } Console.WriteLine($"Total documents retrieved: {allResults.Count}"); // Delete cursor when done (optional - cursor expires after TTL) if (!string.IsNullOrEmpty(response.Id)) { await adb.Cursor.DeleteCursorAsync(response.Id); } ``` -------------------------------- ### Configure SSL/TLS with Certificates Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Connect to secure ArangoDB instances by providing a Base64-encoded CA certificate to the transport layer. ```csharp using ArangoDBNetStandard.Transport.Http; // Base64-encoded CA certificate for SSL connections string encodedCACertificate = "MIIFazCCA1OgAwIBAgIRAI..."; var transport = HttpApiTransport.UsingBasicAuth( new Uri("https://your-instance.arangodb.cloud:8529/"), "myDatabase", "username", "password", HttpContentType.Json, encodedCACertificate); var adb = new ArangoDBClient(transport); ``` -------------------------------- ### Configure JWT Authentication for ArangoDB Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Retrieve a JWT token using the AuthApiClient or initialize transport directly with an existing token string. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.AuthApi; using ArangoDBNetStandard.Transport.Http; // Create transport without authentication var transport = HttpApiTransport.UsingNoAuth( new Uri("http://localhost:8529/"), "myDatabase"); // Create Auth client to get JWT token var authClient = new AuthApiClient(transport); // Get JWT token by submitting credentials var jwtResponse = await authClient.GetJwtTokenAsync("username", "password"); // Set the JWT token on the transport transport.SetJwtToken(jwtResponse.Jwt); // Alternatively, create transport with existing JWT token var jwtTransport = HttpApiTransport.UsingJwtAuth( new Uri("http://localhost:8529/"), "myDatabase", "existingJwtTokenString"); var adb = new ArangoDBClient(jwtTransport); ``` -------------------------------- ### Create Geo-spatial Index in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create a geo-spatial index for location-based queries. Supports GeoJSON format for coordinates. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.IndexApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create geo-spatial index var geoIndex = await adb.Index.PostGeoSpatialIndexAsync( new PostIndexQuery { CollectionName = "Locations" }, new PostGeoSpatialIndexBody { Fields = new[] { "coordinates" }, GeoJson = true, Name = "idx_geo_coordinates" }); Console.WriteLine($"Geo index created: {geoIndex.Id}"); ``` -------------------------------- ### Create Document and Edge Collections Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Configures and creates new collections using the ArangoDBClient. Supports both document and edge collection types. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.CollectionApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create a document collection var response = await adb.Collection.PostCollectionAsync( new PostCollectionBody { Name = "MyCollection", Type = CollectionType.Document, KeyOptions = new CollectionKeyOptions { Type = "traditional", AllowUserKeys = true } }); Console.WriteLine($"Collection ID: {response.Id}"); // Create an edge collection var edgeResponse = await adb.Collection.PostCollectionAsync( new PostCollectionBody { Name = "MyEdges", Type = CollectionType.Edge }); ``` -------------------------------- ### POST /_api/user Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/project/roadmap.md Creates a new user in the ArangoDB database. ```APIDOC ## POST /_api/user ### Description Creates a new user. ### Method POST ### Endpoint /_api/user ``` -------------------------------- ### Configure Custom Serialization for ArangoDB Client Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Demonstrates setting global serialization options via JsonNetApiClientSerialization and overriding them on a per-operation basis. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.Serialization; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); // Use default serialization with custom default options var serializer = new JsonNetApiClientSerialization(); serializer.DefaultOptions.UseCamelCasePropertyNames = true; serializer.DefaultOptions.IgnoreNullValues = true; var adb = new ArangoDBClient(transport, serializer); // Or pass options per operation var options = new ApiClientSerializationOptions { UseCamelCasePropertyNames = true, IgnoreNullValues = false, UseStringEnumConversion = true, IgnoreMissingMember = true }; await adb.Document.PostDocumentAsync( "Products", new Product { Name = "Test", Price = 10.00 }, serializationOptions: options); ``` -------------------------------- ### Configure default serialization options Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/readme.md Updates the default serialization settings for the JsonNetApiClientSerialization implementation. ```csharp var serializer = new JsonNetApiClientSerialization(); serializer.DefaultOptions.IgnoreNullValues = false; ``` -------------------------------- ### Define Document Classes Source: https://github.com/arangodb-community/arangodb-net-standard/blob/master/arangodb-net-standard/Docs/usage.md Defines a simple class for creating documents and a derived class that includes ArangoDB's metadata properties (_key, _id, _rev) for fetching documents. ```csharp class MyClass { public long ItemNumber { get; set; } public string Description { get; set; } } ``` ```csharp class MyClassDocument: MyClass { public string _key { get; set; } public string _id { get; set; } public string _rev { get; set; } } ``` -------------------------------- ### Import Documents in Bulk Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Efficiently import large datasets into ArangoDB collections using either document objects or arrays. Specify collection, import type, and duplicate handling strategy. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.BulkOperationsApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Import using document objects var documentsToImport = new ImportDocumentObjectsBody { Documents = new List { new Product { Name = "Product1", Price = 10.00, Category = "A" }, new Product { Name = "Product2", Price = 20.00, Category = "B" }, new Product { Name = "Product3", Price = 30.00, Category = "C" } } }; var importResponse = await adb.BulkOperations.PostImportDocumentObjectsAsync( new ImportDocumentsQuery { Collection = "Products", Type = ImportDocumentsType.Documents, OnDuplicate = ImportDocumentsOnDuplicate.Update }, documentsToImport); Console.WriteLine($"Created: {importResponse.Created}"); Console.WriteLine($"Updated: {importResponse.Updated}"); Console.WriteLine($"Errors: {importResponse.Errors}"); // Import using arrays format (more efficient for large datasets) var arrayBody = new ImportDocumentArraysBody { Headers = new[] { "Name", "Price", "Category" }, Values = new List { new object[] { "Product4", 40.00, "D" }, new object[] { "Product5", 50.00, "E" }, new object[] { "Product6", 60.00, "F" } } }; var arrayImportResponse = await adb.BulkOperations.PostImportDocumentArraysAsync( new ImportDocumentsQuery { Collection = "Products", OnDuplicate = ImportDocumentsOnDuplicate.Ignore }, arrayBody); Console.WriteLine($"Array import - Created: {arrayImportResponse.Created}"); ``` -------------------------------- ### Manage ArangoSearch Text Analyzers Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create, list, retrieve, and delete analyzers for ArangoSearch views. Requires appropriate permissions on the target database. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.AnalyzerApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create a text analyzer with stemming var analyzer = await adb.Analyzer.PostAnalyzerAsync( new Analyzer { Name = "english_stemmer", Type = "stem", Properties = new AnalyzerProperties { Locale = "en" }, Features = new[] { AnalyzerFeatures.Frequency, AnalyzerFeatures.Position } }); Console.WriteLine($"Analyzer created: {analyzer.Name}"); // Create n-gram analyzer for partial matching var ngramAnalyzer = await adb.Analyzer.PostAnalyzerAsync( new Analyzer { Name = "partial_match", Type = "ngram", Properties = new AnalyzerProperties { Min = 3, Max = 5, PreserveOriginal = true }, Features = new[] { AnalyzerFeatures.Frequency } }); // List all analyzers var analyzers = await adb.Analyzer.GetAllAnalyzersAsync(); foreach (var a in analyzers.Result) { Console.WriteLine($"Analyzer: {a.Name}, Type: {a.Type}"); } // Get specific analyzer var analyzerDetails = await adb.Analyzer.GetAnalyzerAsync("english_stemmer"); // Delete analyzer await adb.Analyzer.DeleteAnalyzerAsync("partial_match"); ``` -------------------------------- ### Delete Documents with ArangoDB .NET Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Demonstrates removing single documents by key or ID, returning old document data, and performing batch deletions. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.DocumentApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Delete document by collection and key await adb.Document.DeleteDocumentAsync("Products", "12345"); // Delete document by document ID await adb.Document.DeleteDocumentAsync("Products/12345"); // Delete and return the old document var deleteResponse = await adb.Document.DeleteDocumentAsync( "Products", "67890", new DeleteDocumentQuery { ReturnOld = true }); Console.WriteLine($"Deleted product: {deleteResponse.Old.Name}"); // Delete multiple documents var keysToDelete = new List { "key1", "key2", "key3" }; var batchDeleteResponse = await adb.Document.DeleteDocumentsAsync( "Products", keysToDelete); foreach (var result in batchDeleteResponse) { Console.WriteLine($"Deleted: {result._key}"); } ``` -------------------------------- ### Create Persistent Index in C# Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Create a persistent index (B-tree) for optimizing query performance on specified fields. The index can be unique or sparse. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.IndexApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Create persistent index (B-tree) var persistentIndex = await adb.Index.PostPersistentIndexAsync( new PostIndexQuery { CollectionName = "Products" }, new PostPersistentIndexBody { Fields = new[] { "Category", "Price" }, Unique = false, Sparse = false, Name = "idx_category_price" }); Console.WriteLine($"Persistent index created: {persistentIndex.Id}"); ``` -------------------------------- ### Manage Collections and Statistics Source: https://context7.com/arangodb-community/arangodb-net-standard/llms.txt Performs administrative tasks on collections including listing, retrieving properties, counting documents, truncating, renaming, and deleting. ```csharp using ArangoDBNetStandard; using ArangoDBNetStandard.CollectionApi.Models; using ArangoDBNetStandard.Transport.Http; var transport = HttpApiTransport.UsingBasicAuth( new Uri("http://localhost:8529/"), "myDatabase", "username", "password"); var adb = new ArangoDBClient(transport); // Get all collections (excluding system collections) var collections = await adb.Collection.GetCollectionsAsync( new GetCollectionsQuery { ExcludeSystem = true }); foreach (var col in collections.Result) { Console.WriteLine($"Collection: {col.Name}, Type: {col.Type}"); } // Get collection properties var props = await adb.Collection.GetCollectionPropertiesAsync("MyCollection"); Console.WriteLine($"WaitForSync: {props.WaitForSync}"); // Get document count var count = await adb.Collection.GetCollectionCountAsync("MyCollection"); Console.WriteLine($"Document count: {count.Count}"); // Get collection figures (statistics) var figures = await adb.Collection.GetCollectionFiguresAsync("MyCollection"); Console.WriteLine($"Documents count: {figures.Figures.DocumentsCount}"); // Truncate collection (remove all documents) await adb.Collection.TruncateCollectionAsync("MyCollection"); // Rename collection await adb.Collection.RenameCollectionAsync("MyCollection", new RenameCollectionBody { Name = "RenamedCollection" }); // Delete collection await adb.Collection.DeleteCollectionAsync("RenamedCollection"); ```