Getting Started

You will learn: why ArangoDB and arango‑typed, install, connect, define schemas, create models, perform CRUD, and enable multi‑tenancy.

Why ArangoDB?

ArangoDB is a multi‑model database: documents, graphs, and key/value in one engine. You can build typical CRUD with documents and run graph traversals (friends, recommendations, paths) without moving data to another system. AQL provides joins, aggregations, and graph operations natively.

Why arango‑typed?

  • Mongoose‑like DX: familiar Schema and model APIs with chainable queries.
  • TypeScript‑first: end‑to‑end types for safety and autocompletion.
  • Production multi‑tenancy: automatic tenant filtering + Express middleware.
  • Performance: connection/query caching, compiled validators, direct DB writes when safe.
  • Graph + Vector: OGM helpers for traversals/paths and built‑in vector search for RAG.

When to choose it

  • Multi‑tenant SaaS with strict isolation and indexes per tenant.
  • Apps combining document storage with graph queries.
  • AI/RAG applications requiring vector search near transactional data.

Installation

npm install arango-typed arangojs

Connect (Mongoose-like)

import { connect } from 'arango-typed';

await connect('http://localhost:8529/myapp', {
  username: 'root', password: ''
});

Alternate connection formats

// Object format
await connect({ url: 'http://localhost:8529', database: 'myapp', username: 'root', password: '' });

// Full options
await connect({ url: 'http://localhost:8529', databaseName: 'myapp', auth: { username: 'root', password: '' } });

Create a Schema and Model

import { Schema, model } from 'arango-typed';

const UserSchema = new Schema({
  name: String,
  email: { type: String, required: true, unique: true }
});

const User = model('users', UserSchema);
const doc = await User.create({ name: 'John', email: 'john@example.com' });

CRUD

// Read
const u = await User.findOne({ email: 'john@example.com' });
// Update
await User.updateOne({ _key: u._key }, { name: 'Johnny' });
// Delete
await User.deleteMany({ email: 'john@example.com' });

Multi‑tenancy (optional)

// app.use(tenantMiddleware({ extractFrom: 'header' }))
// const User = model('users', UserSchema, { tenantEnabled: true })
// All queries are automatically filtered by tenant.
Tip: index your tenant field for best performance (e.g., `tenantId`).

Next: Models & Schemas