teqverse-nosql-sdk
v1.0.9
Published
A client library for interacting with the Teqverse NoSQL database API, suitable for MVPs.
Maintainers
Readme
teqverse-nosql-sdk
A NoSQL Client Library for the PHP File-Based NoSQL Database API by Teqverse.
This SDK lets you interact with your Teqverse NoSQL instance easily from your JavaScript or Node.js applications, abstracting away manual HTTP calls while enabling you to manage collections, documents, files, and user data seamlessly.
🚀 Features
✅ Register & authenticate users
✅ Create, read, update, soft-delete & permanently delete documents
✅ Collection management
✅ File upload & delete
✅ User data backup, restore & export
✅ Public knowledge base management (admin)
✅ System management & maintenance (admin)
📦 Installation
npm install teqverse-nosql-sdkor
yarn add teqverse-nosql-sdk🌱 Basic Usage
1️⃣ Import the SDK
import NoSQLClient from 'teqverse-nosql-sdk';
const client = new NoSQLClient();2️⃣ Register or Login
// Register a new user
await client.registerUser('username', 'password');
// Login
const loginResponse = await client.loginUser('username', 'password');
console.log(loginResponse);3️⃣ Create a Collection
await client.createCollection('my_tasks');4️⃣ Create a Document
const doc = await client.createDocument('my_tasks', { title: 'Buy Groceries', done: false });
console.log(doc);5️⃣ Read a Document
const data = await client.readDocument('my_tasks', doc.id);
console.log(data);6️⃣ Update a Document
await client.updateDocument('my_tasks', doc.id, { done: true });7️⃣ List Documents
const list = await client.listDocuments('my_tasks', { limit: 10, offset: 0 });
console.log(list.documents);8️⃣ Delete a Document
await client.softDeleteDocument('my_tasks', doc.id);📂 File Upload Example
const fileInput = document.querySelector('#fileInput');
const file = fileInput.files[0];
const upload = await client.uploadFile(file);
console.log(upload);🔐 Admin Operations
If your user is an admin (role: 'admin'), you can:
await client.toggleEmergencyMode('enable');
await client.listUsers();
await client.updateUserRole('targetUserId', 'admin');📊 Backups & Exports
// Create a backup
const backup = await client.backupUserData();
// Download the backup
const response = await client.downloadBackup(backup.backup_file);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = backup.backup_file;
document.body.appendChild(link);
link.click();
link.remove();
// Export collection to CSV
await client.exportCollection('my_tasks', 'csv');⚙️ API Reference
The SDK includes the following methods:
registerUser(username, password)loginUser(username, password)createCollection(collectionName)deleteCollection(collectionName)createDocument(collectionName, data)readDocument(collectionName, documentId)updateDocument(collectionName, documentId, newData)softDeleteDocument(collectionName, documentId)permanentDeleteDocument(collectionName, documentId)listDocuments(collectionName, options)searchDocuments(collectionName, query, options)uploadFile(file)deleteFile(filename)backupUserData()downloadBackup(filename)restoreUserData(backupFile)cleanupOldBackups(daysToKeep)promoteDocumentToPublic(collectionName, documentId)demoteDocumentFromPublic(documentId)optimizeDbAndCheckIntegrity(dbType)toggleEmergencyMode(mode)listUsers()updateUserRole(targetUserId, newRole)deleteUser(targetUserId)getSystemStatus()exportCollection(collectionName, format, options)
Each method returns a promise and provides clear error messages for straightforward debugging.
❓ FAQ
Q: What is the backend URL used?
A: It uses https://nosql.teqverse.com.ng/ by default.
Q: Can I use this in the browser?
✅ Yes, it supports modern browsers and Node.js environments.
Q: Does it handle authentication automatically?
⚡️ You handle login and store userId in the session if needed. Use client.setAuth(userId, role) to manually set user authentication if needed.
❤️ Contributions
PRs are welcome to extend this SDK for additional methods or enhancements.
📄 License
MIT License.
📢 Need Help?
For backend setup, guides, or issues, contact [email protected] or visit Teqverse.
