Collection commands provide operations for managing collections within your database.
collection list
List all collections in the database with document counts.
jasonisnthappy < DATABAS E > collection list
Example
jasonisnthappy mydb.db collection list
Output
Collections (3):
• users (1,234 documents)
• orders (5,678 documents)
• products (432 documents)
┌──────────┬───────────┐
│ Name │ Documents │
├──────────┼───────────┤
│ users │ 1,234 │
│ orders │ 5,678 │
│ products │ 432 │
└──────────┴───────────┘
[
{ "name" : "users" , "document_count" : 1234 },
{ "name" : "orders" , "document_count" : 5678 },
{ "name" : "products" , "document_count" : 432 }
]
collection create
Create a new collection. Collections are created automatically on first insert, but explicit creation can be useful for setting up schemas or indexes beforehand.
jasonisnthappy < DATABAS E > collection create < NAM E >
Arguments
name - Name of the collection to create
Example
Create users collection
Create orders collection
jasonisnthappy mydb.db collection create users
Output
✓ Collection 'users' created successfully
Collection names must be unique within a database. Creating a collection that already exists will return an error.
collection drop
Permanently delete a collection and all its documents, indexes, and schemas.
jasonisnthappy < DATABAS E > collection drop < NAM E >
Arguments
name - Name of the collection to drop
Example
jasonisnthappy mydb.db collection drop temp_data
Output
✓ Collection 'temp_data' dropped successfully
Documents deleted: 1,234
Indexes removed: 3
This operation is irreversible. All documents in the collection will be permanently deleted.
collection info
Display detailed information about a specific collection including document count, size, indexes, and schema.
jasonisnthappy < DATABAS E > collection info < NAM E >
Arguments
name - Name of the collection to inspect
Example
jasonisnthappy mydb.db collection info users
Output
Collection: users
Statistics:
Documents: 1,234
Size: 456 KB
Average Document Size: 379 bytes
Indexes:
• email (unique)
• created_at
• age
Schema:
Validation: enabled
Required fields: name, email
Created: 2025-01-15 10:30:22
Modified: 2025-03-03 14:22:11
{
"name" : "users" ,
"document_count" : 1234 ,
"size_bytes" : 467968 ,
"average_doc_size" : 379 ,
"indexes" : [
{ "field" : "email" , "unique" : true },
{ "field" : "created_at" , "unique" : false },
{ "field" : "age" , "unique" : false }
],
"schema" : {
"enabled" : true ,
"required" : [ "name" , "email" ]
},
"created_at" : "2025-01-15T10:30:22Z" ,
"modified_at" : "2025-03-03T14:22:11Z"
}
index list
List all indexes for a collection.
jasonisnthappy < DATABAS E > index list < COLLECTIO N >
Arguments
collection - Name of the collection
Example
jasonisnthappy mydb.db index list users
Output
Indexes for collection 'users':
• email (unique)
• created_at
• age
• status
┌────────────┬────────┐
│ Field │ Unique │
├────────────┼────────┤
│ email │ ✓ │
│ created_at │ │
│ age │ │
│ status │ │
└────────────┴────────┘
[
{ "field" : "email" , "unique" : true },
{ "field" : "created_at" , "unique" : false },
{ "field" : "age" , "unique" : false },
{ "field" : "status" , "unique" : false }
]
index create
Create an index on a field to improve query performance.
jasonisnthappy < DATABAS E > index create < COLLECTIO N > < FIEL D > [--unique]
Arguments
collection - Name of the collection
field - Field name to index (supports dot notation for nested fields)
Flags
--unique / -u - Make this a unique index (prevents duplicate values)
Examples
Regular index
Unique index
Nested field index
jasonisnthappy mydb.db index create users email
Output
✓ Index created on field 'email'
Collection: users
Unique: true
Documents indexed: 1,234
Duration: 45ms
Indexes dramatically improve query performance but use additional disk space. Create indexes for fields you frequently query.
index drop
Remove an index from a collection.
jasonisnthappy < DATABAS E > index drop < COLLECTIO N > < NAM E >
Arguments
collection - Name of the collection
name - Name of the index (field name)
Example
jasonisnthappy mydb.db index drop users email
Output
✓ Index 'email' dropped from collection 'users'
schema set
Set or update the JSON Schema validation for a collection.
jasonisnthappy < DATABAS E > schema set < COLLECTIO N > < SCHEM A >
Arguments
collection - Name of the collection
schema - JSON Schema definition (as JSON string)
Example
jasonisnthappy mydb.db schema set users '{
"type": "object",
"required": ["name", "email"],
"properties": {
"name": {"type": "string"},
"email": {"type": "string", "format": "email"},
"age": {"type": "number", "minimum": 0}
}
}'
Output
✓ Schema set for collection 'users'
Required fields: name, email
Optional fields: age
Setting a schema validates future inserts and updates but doesn’t automatically validate existing documents. Use schema validate to check existing data.
schema get
Retrieve the current schema for a collection.
jasonisnthappy < DATABAS E > schema get < COLLECTIO N >
Arguments
collection - Name of the collection
Example
jasonisnthappy mydb.db schema get users
Output
{
"type" : "object" ,
"required" : [ "name" , "email" ],
"properties" : {
"name" : { "type" : "string" },
"email" : { "type" : "string" , "format" : "email" },
"age" : { "type" : "number" , "minimum" : 0 }
}
}
schema validate
Validate all existing documents in a collection against the current schema.
jasonisnthappy < DATABAS E > schema validate < COLLECTIO N >
Arguments
collection - Name of the collection
Example
jasonisnthappy mydb.db schema validate users
Output
Validating collection 'users'...
✓ Valid documents: 1,230
✗ Invalid documents: 4
Invalid documents:
ID 567: Missing required field 'email'
ID 890: Field 'age' must be >= 0
ID 1024: Invalid email format
ID 1234: Field 'name' must be string
Run schema validation after setting a new schema to identify documents that need updating.
Document commands Insert, query, and modify documents
Database commands Database-level operations