Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikhailsdv/detabase
CLI for Deta Base.
https://github.com/mikhailsdv/detabase
cli deta deta-base
Last synced: 3 months ago
JSON representation
CLI for Deta Base.
- Host: GitHub
- URL: https://github.com/mikhailsdv/detabase
- Owner: mikhailsdv
- Archived: true
- Created: 2022-08-16T13:31:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-30T08:13:50.000Z (11 months ago)
- Last Synced: 2024-03-03T07:36:25.143Z (4 months ago)
- Topics: cli, deta, deta-base
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Lists
- awesome-stars - mikhailsdv/detabase - CLI for Deta Base. (JavaScript)
README
# detabase
[Deta Base](https://docs.deta.sh/docs/base/about) CLI with extended functionality written on Node.js
## Use Cases
- Query, get, put, insert, delete, update items.
- Export databases with or without a specific query.
- Print databases in the table or json view.
- Put or insert data from command line or from file.
- Clone databases with or without a specific query.
- Delete or update multiple items with a query.
- Truncate databases.
- Create empty databases.
- Count items in database.## Usage
```sh
npm install -g @mikhailsdv/detabase
```After installing it, run `detabase --help` without arguments to see list of options:
```console
Usage: detabase [options] [command]Options:
-v, --version Output the current version.
-h, --help Read more information.Commands:
export [options] Create a .json dump of a given database. If no query provided, exports the
whole database.
count [options] Count items of a given database with or without a query.
clone [options] Clone database.
insert [options] Insert items into existing database. Creates a new item only if no item with
the same key exists.
put [options] Put items into existing database. This request overwrites an item if it's key
already exists.
create Creates a database.
truncate Truncates a database.
query [options] Show items matching a query.
delete [options] [key] Deletes an item with the given key or items matching a query.
update [options] [key] Update an item with the given key or items matching a query.
get Get an item with the given key. Use "detabase query " in order to be
able to specify a query.
auth Set your project key.
help [command] Display help for command.
```First thing you need to do is to set your Deta project key by running:
```sh
detabase auth your_project_key
```From now, you can run any command. Note that this project uses Deta's syntax for querying, so whenever you see `` it expects you to use queries as described [here](https://docs.deta.sh/docs/base/http#query-items).
## Available commands
- [export](#export)
- [insert](#insert)
- [put](#put)
- [delete](#delete)
- [update](#update)
- [query](#query)
- [create](#create)
- [clone](#clone)
- [get](#get)
- [truncate](#truncate)
- [count](#count)## export
**Syntax:**
```sh
detabase export -q -li -la -fn
detabase export --query --limit --last -filename
```**Examples:**
```sh
# Export the whole database `users`
detabase export users# Export only users whose age equals to 25
detabase export users -q "{age: 25}"# Export only users whose age is greater than 18
# and save the file in the specific path
detabase export users -q "{'age?gt': 18}" -fn ../folder/export.json
```## insert
**Syntax:**
```sh
detabase insert -i -ff
detabase insert --items --from-file
```**Examples:**
```sh
# Insert an item to database `users`
detabase insert users -i "{name: 'Jack', age: 22}"# Insert two items to database `users`
detabase insert users -i "[{name: 'Jack', age: 22},{name: 'Hanna', age: 25}]"# Insert data from json file
detabase insert users -ff "./some/path/data_to_insert.json"
```## put
**Syntax:**
```sh
detabase put -i -ff
detabase put --items --from-file
```**Examples:**
```sh
# Insert an item to database `users`
detabase put users -i "{name: 'Jack', age: 22}"# Insert two items to database `users`
detabase put users -i "[{name: 'Jack', age: 22},{name: 'Hanna', age: 25}]"# Insert data from json file
detabase put users -ff "./some/path/data_to_insert.json"
```## delete
**Syntax:**
```sh
detabase delete -q
detabase delete --query
```**Examples:**
```sh
# Delete an item from `users` with the key "csn9weej2"
detabase delete users csn9weej2# Delete users with name Jack
detabase delete users -q "{name: 'Jack'}"
```## update
**Syntax:**
```sh
detabase update -q -s -i -a -p -d
detabase update --query --set --increment --append --prepend --delete
```**Examples:**
```sh
# Update an item from `users` with the key "csn9weej2", set name to "Hanna"
detabase update users csn9weej2 --set "{name: 'Hanna'}"# Update users with age = 18, increment their ages by 1.
detabase update users -q "{age: 18}" --increment "{age: 1}"
```## query
**Syntax:**
```sh
detabase query -q -li -la -j
detabase query --query --limit --last --json
```**Examples:**
```sh
# Show all items from `users`
detabase query users# Print a table with users whose age is 18
detabase query users -q "{age: 18}"# Pring json items of users whose age is 18
detabase query users -q "{age: 18}" -j
```## create
**Syntax:**
```sh
detabase create
```**Examples:**
```sh
# Create a database named `new_db`
detabase create new_db
```## clone
**Syntax:**
```sh
detabase clone -q -f
detabase clone --query --force
```**Examples:**
```sh
# Clone `some_db` into `new_db`
detabase clone some_db new_db# Clone `some_db` into `existing_db` even if database with the given name already exists
detabase clone some_db existing_db --force
```## get
**Syntax:**
```sh
detabase get
```**Examples:**
```sh
# Get an item with key "csn9weej2" from `users` database
detabase get users csn9weej2
```## truncate
**Syntax:**
```sh
detabase truncate
```**Examples:**
```sh
# Remove all the items from `users` database
detabase truncate users
```## count
**Syntax:**
```sh
detabase count -q
detabase count --query
```**Examples:**
```sh
# Count items of `users` database
detabase count users# Count items of `users` database where name = 'Jack'
detabase count users -q "{name: 'Jack'}"
```