# Features - A user-friendly admin dashboard for managing your data - A SQL and Websocket playground for testing queries and subscriptions - Support for ACID transactions to ensure data integrity - User authentication for secure access to your data - A SQL API endpoint for querying your data - A Websocket message publishing endpoint for real-time updates - Real-time Websocket subscriptions for monitoring table, document, and key mutations - [TypeScript SDK](https://www.npmjs.com/package/mintdb-js) ### Dependencies ```toml [dependencies] futures = "0.3.25" mintdb = { path = "lib"} once_cell = "1.16.0" serde = { version = "1.0.148", features = ["derive", "rc"] } serde_json = "1.0.89" tokio = { version = "1.22.0", features = ["macros", "sync", "rt-multi-thread", "signal"]} tokio-stream = "0.1.11" uuid = { version = "1.2.2", features = ["serde", "v4"]} warp = "0.3.3" thiserror = "1.0.37" ``` # Get Started Install the mintdb-server binary ``` cargo install mintdb-server@0.1.0-beta.3 ``` Run the server ``` mintdb-server ``` Open http://127.0.0.1:8000 in your browser # SQL API Send a POST request to http://127.0.0.1:8000/sql with the following format ```json { "stmt": "String", "tb": "String", "doc": "String", "data": {}, "topic": "String", "user_id": 1, "message": "String", } ``` ### SELECT Get One Read a user ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "SELECT", "tb": "person", "doc": "person:1", "data": {}, "topic": "", "user_id": 1, "message": "" }' ``` Get All Read all users ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "SELECT", "tb": "person", "doc": "*", "data": {}, "topic": "", "user_id": 1, "message": "" }' ``` ### CREATE Create a user Returns an error if the person already exists ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "CREATE", "tb": "person", "doc": "person:4", "data": { "name": "Ricky", "email": "ricky@gmail.com", "city": "Miami", }, "topic": "", "user_id": 1, "message": "" }' ``` ### MERGE Merge data to a user document. This will create a new table or document if they do not exist. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MERGE", "tb": "person", "doc": "person:4", "data": { "phone": "305 578 5899" }, "topic": "", "user_id": 1, "message": "" }' ``` ### DELETE Delete a document ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "DELETE", "tb": "person", "doc": "person:4", "data": {}, "topic": "", "user_id": 1, "message": "" }' ``` ### FIND Find data by passing a Map of values to match. Returns a vector of documents that match any of the parameters. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "FIND", "tb": "person", "doc": "", "data": { "phone": "305 578 5899" }, "topic": "", "user_id": 1, "message": "" }' ``` ### MATCH Find data by passing a Map of values to match. Returns a vector of documents that match all the parameters. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "person", "doc": "", "data": { "state": "FL", "name": "Lucy" }, "topic": "", "user_id": 1, "message": "" }' ``` ### COMPARE Find data by passing a Map of: ```ts { "lhs": "string", // The key of the document to compare. "op": "operator", // The operation to compare ("==", "!=" "<=" "<" ">=" ">" "contains" or "icontains") "rhs": "string or number" // The value to compare. Contains and icontains must use String } ``` Returns a vector of documents that match the parameters. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "make", "op": "==", "rhs": "Suzuki" }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is not the rhs. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "make", "op": "!=", "rhs": "Suzuki" }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is greater than or equal to the rhs. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "year", "op": ">=", "rhs": 2000 }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is greater than the rhs. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "year", "op": ">", "rhs": 2000 }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is less than or equal to the rhs. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "year", "op": "<=", "rhs": 2000 }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is less than the rhs. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "year", "op": "<", "rhs": 2000 }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is a string and contains the value. Case sensitive. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "model", "op": "contains", "rhs": "AMG" }, "topic": "", "user_id": 1, "message": "" }' ``` Returns a vector of documents where the key is a string and contains the value. Case insensitive. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "MATCH", "tb": "car", "doc": "", "data": { "lhs": "model", "op": "icontains", "rhs": "amg" }, "topic": "", "user_id": 1, "message": "" }' ``` ### INFO Get the keys of all tables in the Database ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "INFO", "tb": "", "doc": "", "data": {}, "topic": "", "user_id": 1, "message": "" }' ``` ### ADD Add a table if it does not exist ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "ADD", "tb": "car", "doc": "", "data": {}, "topic": "", "user_id": 1, "message": "" }' ``` ### PUSH Pushes a value to an array specified by the key. If the key exists and is not an array, an error will be returned. If the key does not exist, a new array is created and the key value pair is inserted into the document. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "PUSH", "tb": "car", "doc": "car:1", "data": { "key":"parts", "value":"engine" }, "topic": "", "user_id": 1, "message": "" }' ``` ### PUT Puts a value into a specified key. If the key exists, the value will be overwritten. If the key does not exist, the key value pair is inserted into the document. ``` curl -X POST 'http://127.0.0.1:8000/sql' -H 'Content-Type: application/json' -d '{ "stmt": "PUT", "tb": "car", "doc": "car:1", "data": { "key":"owner", "value":"person:1" }, "topic": "", "user_id": 1, "message": "" }' ``` ### REL Relates two documents with a specified relationship. The relationship is added as an array in the key "rel: