DataStore is a lightweight database system built with Express.js and SQLite, designed to store and manage data efficiently. It provides RESTful APIs for CRUD operations, table management, and SQL execution.
- Description: Displays a welcome message.
- Route:
GET / - Usage: Accessing the root URL of the application.
- Description: Retrieves a list of all tables in the database.
- Route:
GET /tables - Usage: Lists all existing tables in the SQLite database.
- Description: Retrieves all keys stored in a specified table.
- Route:
GET /:table/keys - Usage: Retrieves all keys stored in the specified
:table.
- Description: Retrieves the count of rows in a specified table, optionally filtered by conditions.
- Route:
GET /:table/count - Usage: Counts the rows in the specified
:table, optionally filtered by query parameters.
- Description: Retrieves data from a specified table, optionally filtered by conditions.
- Route:
GET /:table - Usage: Retrieves data from the specified
:table, optionally filtered by query parameters.
- Description: Retrieves paginated data from a specified table, optionally filtered by conditions.
- Route:
GET /:table/page/:page - Usage: Retrieves paginated data from the specified
:table, with each page containing up to 10 records.
- Description: Inserts new data into the specified table or updates existing data if the key already exists.
- Route:
POST /:table - Usage: Inserts or updates data in the specified
:tablebased on the provided key-value pair.
- Description: Retrieves data from a specified table based on the provided key.
- Route:
GET /:table/:key - Usage: Retrieves data from the specified
:tablebased on the provided:key.
- Description: Deletes a specified table from the database.
- Route:
DELETE /:table - Usage: Deletes the specified
:tableand all its associated data.
- Description: Deletes data from a specified table based on the provided key.
- Route:
DELETE /:table/:key - Usage: Deletes data from the specified
:tablebased on the provided:key.
- Description: Updates data in a specified table based on the provided key.
- Route:
PUT /:table/:key - Usage: Updates data in the specified
:tablebased on the provided:key.
- Description: Executes a custom SQL statement against the SQLite database.
- Route:
POST /sql - Usage: Executes the provided SQL statement and returns the result.
- Insert Data:
POST /users Body: { "key": "example_key", "value": "example_value" } - Retrieve Data:
GET /users/example_key
- Delete Table:
DELETE /users
- Retrieve All Tables:
GET /tables
- Retrieve All Keys from
usersTable:GET /users/keys
- Count Rows in
usersTable:Count Rows inGET /users/count
usersTable with Condition:GET /users/count?condition=value
- Retrieve All Data from
usersTable:Retrieve Data fromGET /users
usersTable with Condition:GET /users?condition=value
- Retrieve Page 1 of Data from
usersTable:GET /users/page/1
- Insert or Update Data in
usersTable:POST /users Body: { "key": "example_key", "value": "updated_value" }
- Retrieve Data with Key
example_keyfromusersTable:GET /users/example_key
- Delete
usersTable:DELETE /users
- Delete Data with Key
example_keyfromusersTable:DELETE /users/example_key
- Update Data with Key
example_keyinusersTable:PUT /users/example_key Body: { "value": "updated_value" }
- Execute Custom SQL Statement:
POST /sql Body: { "sql": "SELECT * FROM users WHERE key = 'example_key'" }
-
Successful Response:
{ "id": 1, "key": "example_key", "value": "updated_value" } -
Error Response:
{ "error": "Key not found" }