simpledb-client
v1.0.1
Published
SimpleDBJS is a JavaScript library for parsing socket output and connecting to SimpleDB. It simplifies interaction with SimpleDB, making database operations easy to integrate into JavaScript applications.
Downloads
5
Readme
SimpleDBJS
SimpleDBJS is a Node.js library that provides a client interface to communicate with SimpleDB, a lightweight Database Management System (DBMS) written in C++. It allows developers to interact with SimpleDB using WebSocket technology, enabling seamless integration with web applications.
Installation
Install SimpleDBJS via npm:
npm install simpledb-client
Usage
Setting Up
Initialize SimpleDBJS with the WebSocket URL:
const { SimpleDBClient } = require('simpledbjs');
const url = 'ws://localhost:8081'; // WebSocket URL to SimpleDB Middleware
const simpleDBClient = new SimpleDBClient(url);
Sending Messages
Send commands to SimpleDB:
const message = 'CREATE table WITH header';
simpleDBClient.sendMessage(message);
Receiving Responses
Handle responses asynchronously:
async function handleResponse() {
const data = await simpleDBClient.getData();
console.log('Received data from SimpleDB:', data.output);
}
Example
const message = 'SELECT *';
simpleDBClient.sendMessage(message);
// Assuming within an async function or using .then()
const data = await simpleDBClient.getData();
console.log('Query results:', data.output);
API Reference
SimpleDBClient(url)
- url: WebSocket URL to SimpleDB Middleware.
Methods
- sendMessage(message): Sends a command message to SimpleDB.
- async getData(): Returns a promise that resolves to the response data from SimpleDB.
Contributing
Contributions are welcome! Please fork the repository and create a pull request with your changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.