🚀 ZTeraDB Quickstart Guide (10-Minute Beginner Setup)
Welcome!
This guide is designed for complete beginners and developers who want to start using ZTeraDB in NodeJS as fast as possible.
Follow this guide step-by-step, and you will run your first ZTeraDB query in under 10 minutes.
✅ 1. Install ZTeraDB NodeJS Client
npm install zteradb
Or with Yarn:
yarn add zteradb
✅ 2. Add Your .env Configuration
Inside your project, create:
.env
Add the following (replace with real keys):
ZTERADB_CONFIG={
"clientKey": "YOUR_CLIENT_KEY",
"accessKey": "YOUR_ACCESS_KEY",
"secretKey": "YOUR_SECRET_KEY",
"databaseID": "YOUR_DATABASE_ID",
"env": "dev",
"responseDataType": "json"
}
⚠️ Never commit .env to GitHub!
✅ 3. Create a Connection File
Create:
db.js
Add this:
import { ZTeraDBConnection } from "zteradb";
export function getDB() {
const config = JSON.parse(process.env.ZTERADB_CONFIG);
const connection = new ZTeraDBConnection(
config,
"db1.zteradb.com",
7777
);
return connection;
}
✅ 4. Run Your First SELECT Query
Create:
test.js
Add:
import { ZTeraDBQuery } from "zteradb";
import { getDB } from "./db.js";
async function main() {
const db = getDB();
const query = new ZTeraDBQuery("user").select();
const result = await db.run(query);
for await (const row of result) {
console.log(row);
}
db.close();
}
main();
Run it:
node test.js
🎉 If everything is correct, you will see your user rows printed!
⚡ 5. INSERT Example
const query = new ZTeraDBQuery("user")
.insert()
.fields({
email: "test@example.com",
password: "pwd",
status: true
});
const result = await db.run(query);
console.log(result.last_insert_id);
⚙ 6. UPDATE Example
const query = new ZTeraDBQuery("user")
.update()
.fields({ status: false })
.filter({ id: 1 });
❌ 7. DELETE Example
const query = new ZTeraDBQuery("user")
.delete()
.filter({ id: 5 });
🔍 8. Filtering (Simple)
query.filter({ status: true });
🔥 9. Filtering (Advanced)
query.filterConditions(
ZTGT([
ZTMUL(["price", "quantity"]),
500
])
);
🎉 10. You Are Ready!
You now know:
- How to install ZTeraDB
- How to configure it
- How to connect
- How to run all basic queries
👉 Next recommended file:
troubleshooting.md