Deta is a Clojure library designed to simplify interactions with the Deta Base and Deta Drive. It provides a straightforward way to initialize a service connection and perform operations. This library is ideal for developers looking to integrate Deta Space services functionality into their Clojure applications.
The current focus is on implementing functions for Deta Base, with Deta Drive functionalities yet to be started.
The Deta Base API provides a range of functionalities for data manipulation. The following functions have been implemented:
- Base Object: Creation and configuration of the base object for API interaction.
- Put: Insertion of an object into the database.
- Get: Retrieval of a specific object from the database.
- Insert: Insertion of a new object into the database.
- Fetch: Retrieval of objects based on specific criteria.
- Delete: Removal of an object from the database.
- Update: Update of an existing object in the database.
The remaining functions to be implemented are:
- Put Many: Insertion of multiple objects into the database at once.
Deta Drive offers functionalities for file storage and manipulation. As of now, work on Deta Drive functionalities has not yet begun. The planned functionalities include:
- Drive Object: Creation and configuration of the drive object for API interaction.
- Put: Upload of a file to Deta Drive.
- Get: Download of a specific file from Deta Drive.
- Delete: Removal of a file from Deta Drive.
- List: Listing of available files in Deta Drive.
- Delete Many: Removal of multiple files from Deta Drive at once.
This project is under continuous development, with the goal of providing a robust and efficient solution for interacting with the Deta Space API in Clojure. Follow the progress and contribute with suggestions or implementations of new functionalities.
- Database Initialization: Easily establish a connection to a Deta database with a straightforward function call.
- Data Insertion: Insert data into the Deta database, supporting various data types.
- Data Update: Update existing data in the Deta database or insert new data if the key does not exist.
- Data Retrieval: Fetch data from the Deta database by specifying a key.
- Data Deletion: Remove data from the Deta database by specifying a key.
- Testing: A comprehensive test suite is essential to ensure reliability and accuracy.
To fully understand how to use this software, referring to the comprehensive documentation available at https://adaiasmagdiel.github.io/deta-clojure/.
- Clojure 1.10 or later
- Leiningen 2.9.1 or later
This library is now available as a dependency. You can add it to your project using Leiningen/Boot by including the following in your project.clj
dependencies:
[com.adaiasmagdiel/deta "0.0.6"]
For more installation methods, such as Clojure CLI/deps.edn
, Gradle
, and Maven
, please refer to the installation section of our documentation.
(def db (base/base "your_collection_key" "your_basename"))
(base/put db {:a 1 :b 2} "item-key")
(base/put db {:c 3 :d 4}) ; The key is automatically generated on the server
(base/insert db {:a 1 :b 2} "item-key")
(base/insert db {:c 3 :d 4}) ; The key is automatically generated on the server
Please refer to the documentation to understand the distinction between "put" and "insert".
(base/get db "item-key")
(base/delete db "item-key")
(base/fetch db) ; Fetch all records
(base/fetch db {:name "Jane Doe"}) ; Fetch only records with name = "Jane Doe"
(base/fetch db {:name "Jane Doe"} {:limit 1 :desc true}) ; Use parameters to modify fetching
(base/update db "key" {:set {:name "John" :age 31 :books []}})
(base/update db "key" {:increment {:age 1}})
(base/update db "key" {:append {:books ["A Book by John Doe", "Another Book By John Doe"]}})
For information on the update payload for the base/update
function, please refer to the Deta Base documentation.
For more detailed usage instructions and examples, please refer to the usage section of our documentation.
The library includes a test suite that covers various scenarios. To run the tests, set the DETA_KEY
environment variable with a valid Deta key beforehand.
set DETA_KEY=your_deta_key_here
lein test
export DETA_KEY=your_deta_key_here
lein test
Replace your_deta_key_here
with your actual Deta key.
This project includes a coverage tool that allows you to easily run test coverage reports. To generate coverage reports for tests, simply enter the following command:
lein cloverage
Contributions are always welcome! Please review the code and send suggestions or pull requests to improve the library.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please open an issue on GitHub.