ndbSDK - Axios SDK for NDB API.
ndbSDK is a Node.js library that provides a convenient wrapper around the NDB API using Axios. It allows you to easily interact with the NDB API and perform common operations such as creating accounts, managing databases, creating tables, and executing table queries.
Installation
To use ndbSDK in your Node.js project, you can install it via npm:
npm install ndb-sdk
Usage
To get started with ndbSDK, require the library and create an instance of the `ndbSDK` class by providing your NDB API username and token:
const ndbSDK = require('ndb-sdk');
const username = 'your-username';
const token = 'your-token';
const sdk = new ndbSDK(username, token);
Managing Databases
You can create a new database using the `makeDB` method:
const database = 'new-database';
sdk.makeDB(database) .then(response => { console.log('Database created successfully:', response); }) .catch(error => { console.error('Failed to create database:', error); });
To drop an existing database, use the `dropDB` method:
const database = 'database-to-drop';
sdk.dropDB(database) .then(response => { console.log('Database dropped successfully:', response); }) .catch(error => { console.error('Failed to drop database:', error); });
Managing Tables
To create a new table in a database, use the `makeTABLE` method:
const db = 'database-name'; const table = 'new-table'; const scheme = [ // Specify the table schema here ];
sdk.makeTABLE(db, table, scheme) .then(response => { console.log('Table created successfully:', response); }) .catch(error => { console.error('Failed to create table:', error); });
To add data to a table, use the `addToTABLE` method:
const db = 'database-name'; const table = 'table-name'; const data = [ // Specify the data to add here ];
sdk.addToTABLE(db, table, data) .then(response => { console.log('Data added successfully:', response); }) .catch(error => { console.error('Failed to add data:', error); });
To drop a table, use the `dropTABLE` method:
const db = 'database-name'; const table = 'table-to-drop';
sdk.dropTABLE(db, table) .then(response => { console.log('Table dropped successfully:', response); }) .catch(error => { console.error('Failed to drop table:', error); });
Querying Tables
To select data from a table, use the `selectTABLE` method:
const db = 'database-name'; const table = 'table-name'; const option = { // Specify the query options here };
sdk.selectTABLE(db, table, option) .then(response => { console.log('Selected data:', response }) .catch(error => { console.error('Failed to select data:', error); });
To delete data from a table, use the deleteFromTABLE method
const db = 'database-name'; const table = 'table-name'; const option = { // Specify the delete options here };
sdk.deleteFromTABLE(db, table, option) .then(response => { console.log('Data deleted successfully:', response); }) .catch(error => { console.error('Failed to delete data:', error); });
To empty a table (delete all data), use the `emptyTABLE` method:
const db = 'database-name'; const table = 'table-name';
sdk.emptyTABLE(db, table) .then(response => { console.log('Table emptied successfully:', response); }) .catch(error => { console.error('Failed to empty table:', error); });
Getting Table Schema
To retrieve the schema of a table, use the `tableSCHEME` method:
const db = 'database-name'; const table = 'table-name';
sdk.tableSCHEME(db, table) .then(response => { console.log('Table schema:', response); }) .catch(error => { console.error('Failed to retrieve table schema:', error); }); }
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on the GitHub repository.
License
This project is licensed under the MIT License.
Feel free to customize the README according to your specific project details and add any additional sections that might be relevant.