Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface EdgeCollection<T>

Represents an edge collection in a Database.

See DocumentCollection for a more generic variant of this interface more suited for regular document collections.

Type parameters

  • T: object

Hierarchy

Implemented by

Index

Properties

Readonly isArangoCollection

isArangoCollection: true
internal

Indicates that this object represents an ArangoDB collection.

Readonly name

name: string

Name of the collection.

Methods

all

any

  • any(): Promise<Edge<T>>
  • TODO

    deprecated

    Simple Queries have been deprecated in ArangoDB 3.4 and can be replaced with AQL queries.

    Returns Promise<Edge<T>>

byExample

checksum

count

create

  • Creates a collection with the given options and the instance's name.

    See also Database.createCollection and Database.createEdgeCollection.

    Note: When called on an EdgeCollection instance in TypeScript, the type option must still be set to the correct CollectionType. Otherwise this will result in the collection being created with the default type (i.e. as a document collection).

    example
    const db = new Database();
    const collection = db.collection("potatoes");
    await collection.create();
    // the document collection "potatoes" now exists
    example
    const db = new Database();
    const collection = db.collection("friends");
    await collection.create({ type: CollectionType.EDGE_COLLECTION });
    // the edge collection "friends" now exists
    example
    interface Friend {
      startDate: number;
      endDate?: number;
    }
    const db = new Database();
    const collection = db.collection("friends") as EdgeCollection<Friend>;
    // even in TypeScript you still need to indicate the collection type
    // if you want to create an edge collection
    await collection.create({ type: CollectionType.EDGE_COLLECTION });
    // the edge collection "friends" now exists

    Parameters

    Returns Promise<ArangoResponseMetadata & CollectionProperties>

document

documentExists

documentId

drop

  • Deletes the collection from the database.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.drop();
    // The collection "some-collection" is now an ex-collection

    Parameters

    Returns Promise<ArangoResponseMetadata>

dropIndex

edge

edges

ensureIndex

exists

  • exists(): Promise<boolean>
  • Checks whether the collection exists.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    const result = await collection.exists();
    // result indicates whether the collection exists

    Returns Promise<boolean>

figures

firstExample

fulltext

get

  • Retrieves general information about the collection.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    const data = await collection.get();
    // data contains general information about the collection

    Returns Promise<ArangoResponseMetadata & CollectionMetadata>

getResponsibleShard

  • getResponsibleShard(document: Partial<Document<T>>): Promise<string>

import

  • Bulk imports the given data into the collection.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.import(
      [
        { _key: "x", _from: "vertices/a", _to: "vertices/b", weight: 1 },
        { _key: "y", _from: "vertices/a", _to: "vertices/c", weight: 2 }
      ]
    );

    Parameters

    Returns Promise<CollectionImportResult>

  • Bulk imports the given data into the collection.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.import(
      [
        [ "_key", "_from", "_to", "weight" ],
        [ "x", "vertices/a", "vertices/b", 1 ],
        [ "y", "vertices/a", "vertices/c", 2 ]
      ]
    );

    Parameters

    • data: any[][]

      The data to import, as an array containing a single array of attribute names followed by one or more arrays of attribute values for each edge document.

    • Optional options: CollectionImportOptions

      Options for importing the data.

    Returns Promise<CollectionImportResult>

  • Bulk imports the given data into the collection.

    If type is omitted, data must contain one JSON array per line with the first array providing the attribute names and all other arrays providing attribute values for each edge document.

    If type is set to "documents", data must contain one JSON document per line.

    If type is set to "list", data must contain a JSON array of edge documents.

    If type is set to "auto", data can be in either of the formats supported by "documents" or "list".

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.import(
      '{"_key":"x","_from":"vertices/a","_to":"vertices/b","weight":1}\r\n' +
      '{"_key":"y","_from":"vertices/a","_to":"vertices/c","weight":2}\r\n',
      { type: "documents" } // or "auto"
    );
    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.import(
      '[{"_key":"x","_from":"vertices/a","_to":"vertices/b","weight":1},' +
      '{"_key":"y","_from":"vertices/a","_to":"vertices/c","weight":2}]',
      { type: "list" } // or "auto"
    );
    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.import(
      '["_key","_from","_to","weight"]\r\n' +
      '["x","vertices/a","vertices/b",1]\r\n' +
      '["y","vertices/a","vertices/c",2]\r\n'
    );

    Parameters

    • data: Buffer | Blob | string

      The data to import as a Buffer (Node), Blob (browser) or string.

    • Optional options: CollectionImportOptions & { type?: "documents" | "list" | "auto" }

      Options for importing the data.

    Returns Promise<CollectionImportResult>

inEdges

index

indexes

  • indexes(): Promise<Index[]>

list

load

  • Instructs ArangoDB to load the collection into memory.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.load();
    // the collection has now been loaded into memory

    Parameters

    • Optional count: undefined | true

      Whether the number of documents in the collection should be included in the server response. Disabling this may speed up this process in future versions of ArangoDB.

    Returns Promise<ArangoResponseMetadata & CollectionMetadata & CollectionCount>

  • Instructs ArangoDB to load the collection into memory.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.load(false);
    // the collection has now been loaded into memory

    Parameters

    • count: false

      Whether the number of documents in the collection should be included in the server response. Disabling this may speed up this process in future versions of ArangoDB.

    Returns Promise<ArangoResponseMetadata & CollectionMetadata>

loadIndexes

  • loadIndexes(): Promise<boolean>
  • (RocksDB only.) Instructs ArangoDB to load as many indexes of the collection into memory as permitted by the memory limit.

    example
    const db = new Database();
    const collection = db.collection("indexed-collection");
    await collection.loadIndexes();
    // the indexes are now loaded into memory

    Returns Promise<boolean>

lookupByKeys

  • lookupByKeys(keys: string[]): Promise<Edge<T>[]>
  • TODO

    deprecated

    Simple Queries have been deprecated in ArangoDB 3.4 and can be replaced with AQL queries.

    Parameters

    • keys: string[]

    Returns Promise<Edge<T>[]>

outEdges

properties

recalculateCount

  • recalculateCount(): Promise<boolean>
  • (RocksDB only.) Instructs ArangoDB to recalculate the collection's document count to fix any inconsistencies.

    example
    const db = new Database();
    const collection = db.collection("inconsistent-collection");
    const badData = await collection.count();
    // oh no, the collection count looks wrong -- fix it!
    await collection.recalculateCount();
    const goodData = await collection.count();
    // goodData contains the collection's improved count

    Returns Promise<boolean>

remove

removeAll

removeByExample

removeByKeys

rename

  • Renames the collection and updates the instance's name to newName.

    Additionally removes the instance from the Database's internal cache.

    Note: Renaming collections may not be supported when ArangoDB is running in a cluster configuration.

    example
    const db = new Database();
    const collection1 = db.collection("some-collection");
    await collection1.rename("other-collection");
    const collection2 = db.collection("some-collection");
    const collection3 = db.collection("other-collection");
    // Note all three collection instances are different objects but
    // collection1 and collection3 represent the same ArangoDB collection!

    Parameters

    • newName: string

      The new name of the collection.

    Returns Promise<ArangoResponseMetadata & CollectionMetadata>

replace

replaceAll

replaceByExample

revision

rotate

  • rotate(): Promise<boolean>
  • (MMFiles single-server only.) Rotates the journal of the collection.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    const rotated = await collection.rotate();

    Returns Promise<boolean>

save

saveAll

traversal

  • TODO

    deprecated

    Simple Queries have been deprecated in ArangoDB 3.4 and can be replaced with AQL queries.

    Parameters

    Returns Promise<any>

truncate

  • Deletes all documents in the collection.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.truncate();
    // millions of documents cry out in terror and are suddenly silenced,
    // the collection "some-collection" is now empty

    Returns Promise<ArangoResponseMetadata & CollectionMetadata>

unload

  • Instructs ArangoDB to remove the collection from memory.

    example
    const db = new Database();
    const collection = db.collection("some-collection");
    await collection.unload();
    // the collection has now been unloaded from memory

    Returns Promise<ArangoResponseMetadata & CollectionMetadata>

update

updateAll

updateByExample

Generated using TypeDoc