@atscript/db-mongo
v0.1.50
Published
Mongodb plugin for atscript.
Downloads
1,308
Readme
MongoDB adapter for @atscript/db. Translates Atscript's portable query model into native MongoDB operations with support for Atlas Search, vector search, aggregation pipelines, capped collections, and the Convenient Transaction API.
Includes MongoPlugin for @db.mongo.* annotations and custom primitives (mongo.objectId, mongo.vector).
Installation
pnpm add @atscript/db-mongo mongodbQuick Start
import { DbSpace } from "@atscript/db";
import { MongoAdapter } from "@atscript/db-mongo";
import { MongoClient } from "mongodb";
const client = new MongoClient("mongodb://localhost:27017/myapp");
const db = new DbSpace(() => new MongoAdapter(client.db(), client));
const todos = db.getTable(TodoType);
await todos.insertOne({ title: "Hello", done: false });Features
- Full CRUD with native MongoDB operations
- Atlas Search: dynamic and static text indexes with analyzers and fuzzy matching
- Vector search via
@db.search.vectorwith configurable dimensions and similarity - Native relation loading via
$lookupaggregation stages - Aggregation pipeline support
- Array patch operations via
CollectionPatcher - Capped collections via
@db.mongo.capped - Auto-increment via atomic counter collection
- Convenient Transaction API with automatic retry
Documentation
License
MIT
