NoSQL Cheat Sheet

What is NoSQL?

  • NoSQL (“Not Only SQL”) databases store and retrieve data differently than relational databases.
  • Designed for scalability, flexibility, and high performance.
  • Often used for big data, real-time applications, and distributed systems.

Popular NoSQL Databases

  • MongoDB – Document store, supports ACID transactions and aggregation framework.
  • Redis – In-memory key-value store, supports caching, pub/sub, and Lua scripting.

MongoDB Commands

Database Management

CommandsDescription
show dbsList databases
use myDatabaseSelect database
db.createCollection("users")Create collection
db.users.insertOne({ name: "Alice", age: 25 })Insert document
db.users.insertMany([{ name: "Bob" }, { name: "Charlie" }])Insert multiple documents

Collection Management

CommandsDescription
db.createCollection(‘users’)Create a new collection
db.getCollectionNames()List all collections
db.users.renameCollection(‘customers’)Rename a collection
db.users.drop()Drop a collection
db.users.stats()Get collection statistics

CRUD Operations

CommandsDescription
db.users.insertOne({ name: ‘John’ })Insert a single document
db.users.insertMany([{ name: ‘Alice’ }, { name: ‘Bob’ }])Insert multiple documents
db.users.find()Find all documents
db.users.findOne()Find a single document
db.users.updateOne({ name: ‘John’ }, { $set: { age: 30 } })Update a single document

Indexing

CommandsDescription
db.users.createIndex({ name: 1 })Create an ascending index
db.users.createIndex({ age: -1 })Create a descending index
db.users.getIndexes()List all indexes
db.users.dropIndex(‘name_1’)Drop an index
db.users.reIndex()Rebuild all indexes

Security & Authentication

CommandsDescription
db.createUser({ user: ‘admin’, pwd: ‘password’, roles: [‘readWrite’] })Create a new user
db.auth(‘admin’, ‘password’)Authenticate a user
db.updateUser(‘admin’, { roles: [‘dbAdmin’] })Modify a user’s roles
db.getUsers()List all users
db.dropUser(‘user’)Remove a user

Buy Complete Cheatsheet In PDF Format

NoSQL Cheat Sheet (MongoDB)

$2.99

Tired of constantly searching for MongoDB commands? This NoSQL Cheat Sheet (MongoDB) is your go-to guide for creating databases, running queries, filtering data, and optimizing performance. It’s perfect for beginners and pros alike. Save time, avoid frustration, and master MongoDB effortlessly—grab your copy now!

Category:

Redis Commands

Connection & Server

CommandsDescription
PINGTest connection (returns PONG)
AUTH passwordAuthenticate to the server
SELECT indexChange the selected database
QUITClose the connection
INFOGet server information and statistics

Key Management

CommandsDescription
SET key valueSet key to hold string value
GET keyGet value of key
DEL key [key …]Delete one or more keys
EXISTS key [key …]Check if key(s) exist
EXPIRE key secondsSet key expiration time in seconds

Strings

CommandsDescription
SET key valueSet string value of a key
GET keyGet string value of a key
APPEND key valueAppend to string value of a key
INCR keyIncrement integer value by 1
DECR keyDecrement integer value by 1

Lists

CommandsDescription
LPUSH key value [value …]Prepend values to a list
RPUSH key value [value …]Append values to a list
LPOP keyRemove and get first element
RPOP keyRemove and get last element
LLEN keyGet list length

Sets

CommandsDescription
SADD key member [member …]Add members to set
SREM key member [member …]Remove members from set
SMEMBERS keyGet all members in set
SISMEMBER key memberTest if member is in set
SCARD keyGet set cardinality (size)

Buy Complete Cheatsheet In PDF Format

NoSQL Cheat Sheet (Redis)

$2.99

Tired of Googling Redis commands again and again? This NoSQL Redis Cheat Sheet is your go-to quick reference. Perfect for beginners and busy devs, it helps you work faster, smarter, and with way less stress. Make Redis feel easy, finally!

Category:

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart