@joktec/arango
v0.2.12
Published
JokTec - ArangoDB Service
Readme
@joktec/arango
ArangoDB database package for JokTec applications.
@joktec/arango wraps the ArangoDB JavaScript driver with JokTec config parsing, lifecycle hooks, collection helpers, bulk upsert support, and AQL query execution.
What It Provides
ArangoModuleglobal Nest module.ArangoServicebuilt onAbstractClientService.- ArangoDB client interface, config, and models.
- Basic and bearer credential config contracts.
ArangoDocumentandArangoQueryRequesttypes.
Install
yarn add @joktec/arangoUsage
import { ArangoModule, ArangoService } from '@joktec/arango';
@Module({
imports: [ArangoModule],
})
export class AppModule {}Inject ArangoService into app services:
const cursor = await arangoService.query<{ name: string }>(aql`
FOR doc IN users
FILTER doc.status == "active"
RETURN doc
`);
const users = await cursor.all();Bulk upsert is available for document arrays:
await arangoService.bulkUpsert('users', docs, ['_key']);Config
Configure the arango section in the application config. Multiple connections are selected with conId.
arango:
conId: default
url: http://localhost:8529
databaseName: joktec
auth:
username: root
password: root
maxRetries: 3auth can be basic credentials or bearer credentials depending on the target ArangoDB setup.
Guidelines
- Keep collection names, graph semantics, and AQL query ownership in the consuming app.
- Use
_keyor explicit upsert fields for deterministic bulk upserts. - Keep long-running graph/search workloads visible at the app/service layer.
- Package tests mock
arangojs; use live stack scenarios only when a local ArangoDB service is available.
Development
yarn lint --scope @joktec/arango
yarn build --scope @joktec/arango
yarn test --scope @joktec/arango