npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mikhailsdv/detabase

v1.1.4

Published

CLI for Deta Base.

Downloads

3

Readme

detabase

Deta Base 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

npm install -g @mikhailsdv/detabase

After installing it, run detabase --help without arguments to see list of options:

Usage: detabase [options] [command]

Options:
  -v, --version                          Output the current version.
  -h, --help                             Read more information.

Commands:
  export [options] <database>            Create a .json dump of a given database. If no query provided, exports the
                                         whole database.
  count [options] <database>             Count items of a given database with or without a query.
  clone [options] <database> <new-name>  Clone database.
  insert [options] <database>            Insert items into existing database. Creates a new item only if no item with
                                         the same key exists.
  put [options] <database>               Put items into existing database. This request overwrites an item if it's key
                                         already exists.
  create <database>                      Creates a database.
  truncate <database>                    Truncates a database.
  query [options] <database>             Show items matching a query.
  delete [options] <database> [key]      Deletes an item with the given key or items matching a query.
  update [options] <database> [key]      Update an item with the given key or items matching a query.
  get <database> <key>                   Get an item with the given key. Use "detabase query <query>" in order to be
                                         able to specify a query.
  auth <project-key>                     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:

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 <query> it expects you to use queries as described here.

Available commands

export

Syntax:

detabase export <database> -q <query> -li <limit> -la <last> -fn <filename>
detabase export <database> --query <query> --limit <limit> --last <last> -filename <filename>

Examples:

# 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:

detabase insert <database> -i <items> -ff <from-file>
detabase insert <database> --items <items> --from-file <from-file>

Examples:

# 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:

detabase put <database> -i <items> -ff <from-file>
detabase put <database> --items <items> --from-file <from-file>

Examples:

# 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:

detabase delete <database> -q <query>
detabase delete <database> --query <query>

Examples:

# 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:

detabase update <database> -q <query> -s <object> -i <object> -a <object> -p <object> -d <string, array>
detabase update <database> --query <query> --set <object> --increment <object> --append <object> --prepend <object> --delete <string, array>

Examples:

# 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:

detabase query <database> -q <query> -li <limit> -la <last> -j
detabase query <database> --query <query> --limit <limit> --last <last> --json

Examples:

# 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:

detabase create <database>

Examples:

# Create a database named `new_db`
detabase create new_db

clone

Syntax:

detabase clone <database> <new-name> -q <query> -f
detabase clone <database> <new-name> --query <query> --force

Examples:

# 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:

detabase get <database> <key>

Examples:

# Get an item with key "csn9weej2" from `users` database
detabase get users csn9weej2

truncate

Syntax:

detabase truncate <database>

Examples:

# Remove all the items from `users` database
detabase truncate users

count

Syntax:

detabase count <database> -q <query>
detabase count <database> --query <query>

Examples:

# Count items of `users` database
detabase count users

# Count items of `users` database where name = 'Jack'
detabase count users -q "{name: 'Jack'}"