Skip to content

Commit b820f09

Browse files
committed
More examples
1 parent 537de08 commit b820f09

File tree

4 files changed

+151
-11
lines changed

4 files changed

+151
-11
lines changed

src/analyzer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ export class Analyzer {
319319
*
320320
* @example
321321
* ```js
322-
* TODO
322+
* const db = new Database();
323+
* const analyzer = db.analyzer("potatoes");
324+
* await analyzer.create({ type: "identity" });
325+
* // the identity Analyzer "potatoes" now exists
323326
* ```
324327
*/
325328
create(options: CreateAnalyzerOptions): Promise<AnalyzerDescription> {

src/graph.ts

Lines changed: 142 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,17 @@ export class Graph {
13461346
*
13471347
* @example
13481348
* ```js
1349-
* TODO
1349+
* const db = new Database();
1350+
* const graph = db.graph("some-graph");
1351+
* const info = await graph.create([
1352+
* {
1353+
* collection: "edges",
1354+
* from: ["start-vertices"],
1355+
* to: ["end-vertices"],
1356+
* },
1357+
* ]);
1358+
* const vertexCollectionNames = await graph.listVertexCollections();
1359+
* // ["start-vertices", "end-vertices"]
13501360
* ```
13511361
*/
13521362
listVertexCollections(): Promise<string[]> {
@@ -1361,6 +1371,25 @@ export class Graph {
13611371
* an array of {@link GraphVertexCollection} instances.
13621372
*
13631373
* See also {@link Graph.listVertexCollections}.
1374+
*
1375+
* @example
1376+
* ```js
1377+
* const db = new Database();
1378+
* const graph = db.graph("some-graph");
1379+
* const info = await graph.create([
1380+
* {
1381+
* collection: "edges",
1382+
* from: ["start-vertices"],
1383+
* to: ["end-vertices"],
1384+
* },
1385+
* ]);
1386+
* const vertexCollections = await graph.vertexCollections();
1387+
* for (const vertexCollection of vertexCollections) {
1388+
* console.log(vertexCollection.name);
1389+
* // "start-vertices"
1390+
* // "end-vertices"
1391+
* }
1392+
* ```
13641393
*/
13651394
async vertexCollections(): Promise<GraphVertexCollection[]> {
13661395
const names = await this.listVertexCollections();
@@ -1374,7 +1403,13 @@ export class Graph {
13741403
*
13751404
* @example
13761405
* ```js
1377-
* TODO
1406+
* const db = new Database();
1407+
* const graph = db.graph("some-graph");
1408+
* await graph.addVertexCollection("more-vertices");
1409+
* // The collection "more-vertices" has been added to the graph
1410+
* const extra = db.collection("extra-vertices");
1411+
* await graph.addVertexCollection(extra);
1412+
* // The collection "extra-vertices" has been added to the graph
13781413
* ```
13791414
*/
13801415
addVertexCollection(
@@ -1402,7 +1437,17 @@ export class Graph {
14021437
*
14031438
* @example
14041439
* ```js
1405-
* TODO
1440+
* const db = new Database();
1441+
* const graph = db.graph("some-graph");
1442+
* const info = await graph.create([
1443+
* {
1444+
* collection: "edges",
1445+
* from: ["start-vertices"],
1446+
* to: ["end-vertices"],
1447+
* },
1448+
* ]);
1449+
* await graph.removeVertexCollection("start-vertices");
1450+
* // The collection "start-vertices" is no longer part of the graph.
14061451
* ```
14071452
*/
14081453
removeVertexCollection(
@@ -1430,6 +1475,22 @@ export class Graph {
14301475
*
14311476
* @param T - Type to use for document data. Defaults to `any`.
14321477
* @param collection - Name of the edge collection.
1478+
*
1479+
* @example
1480+
* ```js
1481+
* const db = new Database();
1482+
* const graph = db.graph("some-graph");
1483+
* const info = await graph.create([
1484+
* {
1485+
* collection: "edges",
1486+
* from: ["start-vertices"],
1487+
* to: ["end-vertices"],
1488+
* },
1489+
* ]);
1490+
* const graphEdgeCollection = graph.edgeCollection("edges");
1491+
* // Access the underlying EdgeCollection API:
1492+
* const edgeCollection = graphEdgeCollection.collection;
1493+
* ```
14331494
*/
14341495
edgeCollection<T extends object = any>(
14351496
collection: string | ArangoCollection
@@ -1448,7 +1509,17 @@ export class Graph {
14481509
*
14491510
* @example
14501511
* ```js
1451-
* TODO
1512+
* const db = new Database();
1513+
* const graph = db.graph("some-graph");
1514+
* const info = await graph.create([
1515+
* {
1516+
* collection: "edges",
1517+
* from: ["start-vertices"],
1518+
* to: ["end-vertices"],
1519+
* },
1520+
* ]);
1521+
* const edgeCollectionNames = await graph.listEdgeCollections();
1522+
* // ["edges"]
14521523
* ```
14531524
*/
14541525
listEdgeCollections(): Promise<string[]> {
@@ -1463,6 +1534,24 @@ export class Graph {
14631534
* an array of {@link GraphEdgeCollection} instances.
14641535
*
14651536
* See also {@link Graph.listEdgeCollections}.
1537+
*
1538+
* @example
1539+
* ```js
1540+
* const db = new Database();
1541+
* const graph = db.graph("some-graph");
1542+
* const info = await graph.create([
1543+
* {
1544+
* collection: "edges",
1545+
* from: ["start-vertices"],
1546+
* to: ["end-vertices"],
1547+
* },
1548+
* ]);
1549+
* const graphEdgeCollections = await graph.edgeCollections();
1550+
* for (const collection of graphEdgeCollection) {
1551+
* console.log(collection.name);
1552+
* // "edges"
1553+
* }
1554+
* ```
14661555
*/
14671556
async edgeCollections(): Promise<GraphEdgeCollection[]> {
14681557
const names = await this.listEdgeCollections();
@@ -1476,7 +1565,14 @@ export class Graph {
14761565
*
14771566
* @example
14781567
* ```js
1479-
* TODO
1568+
* const db = new Database();
1569+
* const graph = db.graph("some-graph");
1570+
* await graph.addEdgeDefinition({
1571+
* collection: "edges",
1572+
* from: ["start-vertices"],
1573+
* to: ["end-vertices"],
1574+
* });
1575+
* // The edge definition has been added to the graph
14801576
* ```
14811577
*/
14821578
addEdgeDefinition(edgeDefinition: EdgeDefinitionOptions): Promise<GraphInfo> {
@@ -1498,7 +1594,21 @@ export class Graph {
14981594
*
14991595
* @example
15001596
* ```js
1501-
* TODO
1597+
* const db = new Database();
1598+
* const graph = db.graph("some-graph");
1599+
* const info = await graph.create([
1600+
* {
1601+
* collection: "edges",
1602+
* from: ["start-vertices"],
1603+
* to: ["end-vertices"],
1604+
* },
1605+
* ]);
1606+
* await graph.replaceEdgeDefinition({
1607+
* collection: "edges",
1608+
* from: ["start-vertices"],
1609+
* to: ["other-vertices"],
1610+
* });
1611+
* // The edge definition for "edges" has been replaced
15021612
* ```
15031613
*/
15041614
replaceEdgeDefinition(
@@ -1513,7 +1623,21 @@ export class Graph {
15131623
*
15141624
* @example
15151625
* ```js
1516-
* TODO
1626+
* const db = new Database();
1627+
* const graph = db.graph("some-graph");
1628+
* const info = await graph.create([
1629+
* {
1630+
* collection: "edges",
1631+
* from: ["start-vertices"],
1632+
* to: ["end-vertices"],
1633+
* },
1634+
* ]);
1635+
* await graph.replaceEdgeDefinition("edges", {
1636+
* collection: "edges",
1637+
* from: ["start-vertices"],
1638+
* to: ["other-vertices"],
1639+
* });
1640+
* // The edge definition for "edges" has been replaced
15171641
* ```
15181642
*/
15191643
replaceEdgeDefinition(
@@ -1550,7 +1674,17 @@ export class Graph {
15501674
*
15511675
* @example
15521676
* ```js
1553-
* TODO
1677+
* const db = new Database();
1678+
* const graph = db.graph("some-graph");
1679+
* const info = await graph.create([
1680+
* {
1681+
* collection: "edges",
1682+
* from: ["start-vertices"],
1683+
* to: ["end-vertices"],
1684+
* },
1685+
* ]);
1686+
* await graph.removeEdgeDefinition("edges");
1687+
* // The edge definition for "edges" has been replaced
15541688
* ```
15551689
*/
15561690
removeEdgeDefinition(

src/test/27-query-management.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe("Query Management API", function () {
224224
});
225225
});
226226

227-
// TODO rewrite this test to use async mode to eliminate the timing
227+
// FIXME rewrite this test to use async mode to eliminate the timing
228228
// dependence. This test is flakey on Jenkins otherwise.
229229
describe.skip("database.killQuery", () => {
230230
it("kills the given query", async () => {

src/view.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,10 @@ export class View<
411411
*
412412
* @example
413413
* ```js
414-
* TODO
414+
* const db = new Database();
415+
* const view = db.view("potatoes");
416+
* await view.create();
417+
* // the ArangoSearch View "potatoes" now exists
415418
* ```
416419
*/
417420
create(

0 commit comments

Comments
 (0)