direct-db
v1.0.0
Published
use plain english to db queries
Downloads
4
Readme
direct-db
AI-powered database interaction for Node.js.direct-db lets your backend read and understand natural language instructions, then translate them into MongoDB queries — no manual query building needed.
🚀 Installation
npm install direct-db🔑 Hugging Face Token
direct-db uses Hugging Face models for natural language → query conversion.
You’ll need an API token from: ➡ https://huggingface.co/settings/tokens
Parameters
instruction — A natural language request (e.g., "Find all users older than 25").
Model — Mongoose models, keyed by name.
token — Hugging Face API token.
Example APIs
readRequest
send instruction of what u want to fetch and directly get it
import { readRequest } from "direct-db";
app.post("/read", async (req, res) => {
try {
const { instruction } = req.body;
const result = await readRequest(instruction, { Model }, token);
res.json({ success: true, result });
} catch (err) {
res.status(500).json({ success: false, error: err.message });
}
});schemaRequest
gives an overview of what the schema looks like
import { schemaRequest } from "direct-db";
app.get("/schema", async (req, res) => {
try {
const schemaInfo = await schemaRequest({ Model });
res.json({ success: true, schema: schemaInfo });
} catch (err) {
res.status(500).json({ success: false, error: err.message });
}
});