- Clone the repo -
git clone https://github.com/pranavnt/caldera && cd caldera - Install dependencies -
go get - Build caldera -
go build caldera.go
When a user signs up, send a POST request to /signUp with the following JSON:
{
"username": "username",
"password": "password"
}Your username and password will be saved (password will be encrypted), and you will be returned with your userid!
When a user trys to login, send a POST request to /login with the following JSON:
{
"username": "username",
"password": "password"
}If it is successful, you will be returned with your userid, and if not, you'll be returned with a message saying that your password was incorrect or you haven't signed up.
In order to create a collection, run the command caldera create collection collectionName into terminal, as a collection with collectionName will be created. This can only be done from the command line for now, but I'm hoping to allow devs to be able to do this through an API in the future.
Send a POST request to /api/collection/{collectionName}/create/document where collectionName is the name of the collection the document should be created in.
You should post the json you want to be stored in that document, with the key of uid being the user id. Here is sample JSON that could be posted:
{
"uid": "userid",
"data1": "hello",
"key2": "world"
}To get a document by its id, send a GET request to /api/collection/{collectionName}/document/read/{_id}, where _id is the document id and collectionName is the name of the collection.
To get all documents from a collection from a given user, send a GET request to /api/collection/{collectionName}/document/read/user/{uid}, where uid is the user id, and collectionName is the name of the collection.
To get all documents from a collection, send a GET request to /api/collection/{collectionName}/all, where collectionName is the name of the collection.
To update an element in a collection, send a POST request to /api/collection/todos/document/update/{_id}, where _id is the document id. You need to post the new JSON that should be stored in that document along with the user id. Here is sample JSON that can be posted:
{
"uid": "userid",
"data1": "world",
"key2": "hello"
}To update the name of a collection, run the command caldera update collection oldName newName, where oldName is the name of the collection, and newName is the new name!
To delete a document from a collection, send a GET request to /api/collection/todos/document/delete/{uid}/{_id}. Here, uid will be the userid and _id will be the document id.
To delete a collection, run the command caldera delete collection collectionName into terminal, and the collection with the name collectionName will be deleted. You can only do this through the CLI right now, but I'm hoping to make this accessible via an API in the future.
d
When building full stack apps, I often get tired of building an API, which interacts with a database for really simple operations.
