Class ArangoDBWithSpice

A thin wrapper around an ArangoJS Database instance. It provides direct and easy access to the ArangoJS instance itself, but also adds a few convenience methods, for optional use.

The constructor accepts an ArangoJS Config

import { aql } from "arangojs/aql";
import { ArangoDB } from "@distributhor/guacamole";

const db = new ArangoDB({ databaseName: "name", url: "http://127.0.0.1:8529", auth: { username: "admin", password: "letmein" } });

// the native ArangoJS driver instance is exposed on the `db.driver` property
db.driver.query(aql`FOR d IN user FILTER d.name LIKE ${name} RETURN d`);

// the backseat driver method, which immediately calls cursor.all()
// on the results, returning all the documents, and not the cursor
db.query(aql`FOR d IN user FILTER d.name LIKE ${name} RETURN d`);

Hierarchy

Constructors

Properties

driver: Database

A property that exposes the native ArangoJS Database instance.

system: Database

Accessors

  • get dbName(): string
  • Returns string

Methods

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • arrayObject: any
    • Optional uniqueObjectField: string
    • Optional options: any

    Returns Promise<DocumentMeta[]>

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • arrayValue: any
    • Optional options: any

    Returns Promise<DocumentMeta[]>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    • collection: string

    Returns DocumentCollection<T> | EdgeCollection<T>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    • collection: string
    • data: DocumentData<T> | DocumentData<T>[]
    • Optional options: CollectionInsertOptions

    Returns Promise<(DocumentMetadata & {
        _oldRev?: string;
    } & {
        new?: Document<T>;
        old?: Document<T>;
    })[]>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    Returns Promise<(DocumentMetadata & {
        _oldRev?: string;
    } & {
        new?: Document<T>;
        old?: Document<T>;
    })[]>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    • collection: string
    • identifier: DocumentSelector | (string | ObjectWithKey)[] | Identifier
    • Optional dependencies: any[]
    • Optional options: CollectionRemoveOptions

    Returns Promise<(DocumentMetadata & {
        old?: Document<T>;
    })[]>

  • Type Parameters

    • T = any

    Parameters

    • collection: string
    • identifier: DocumentSelector | Identifier
    • property: string

    Returns Promise<null | T | T[]>

  • The regular driver.query method will return a database cursor. If you wish to just return all the documents in the result at once (same as invoking cursor.all()), then use this method instead.

    TODO: support for generic types on the retun value

    Returns

    a list of objects

    Type Parameters

    • T = any

    Parameters

    • query: string | AqlQuery<any> | LiteralQuery

      A query, as create by the aql function

    • Optional options: QueryOptions

      Driver options that may be passed in along with the query

    Returns Promise<ArrayCursor<T>>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    Returns Promise<null | Document<T>>

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • objectIdField: string
    • objectIdValue: any

    Returns Promise<null | DocumentMeta[]>

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • arrayValue: any

    Returns Promise<null | DocumentMeta[]>

  • Parameters

    • collection: string
    • identifier: DocumentSelector | Identifier
    • arrayProperty: string
    • updatedArray: any[]

    Returns Promise<null | DocumentMeta[]>

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • objectIdField: string
    • objectIdValue: any
    • updatedObject: any
    • Optional options: any

    Returns Promise<null | DocumentMeta[]>

  • Will only return the first value of a query result. One can quite easily handle this via the AQL query itself, but in cases where you have issued a query where you would typically expect either no result or exactly one result, or are only interested in the first result, it may convenient to simply use use this function instead

    Returns

    an object

    Type Parameters

    • T = any

    Parameters

    • query: string | AqlQuery<any> | LiteralQuery

      A query, as create by the aql function

    • Optional options: FetchOptions

      Driver options that may be passed in along with the query

    Returns Promise<null | T | T[]>

  • Type Parameters

    • T extends Record<string, any> = any

    Parameters

    Returns Promise<(DocumentMetadata & {
        _oldRev?: string;
    } & {
        new?: Document<T>;
        old?: Document<T>;
    })[]>

  • Parameters

    • collection: string
    • key: string
    • arrayProperty: string
    • objectIdField: string
    • objectIdValue: any
    • updatedObject: any
    • Optional options: any

    Returns Promise<null | DocumentMeta[]>

Generated using TypeDoc