Skip to content
Mauricio David edited this page Mar 17, 2015 · 16 revisions

LiteDB project has a simple console application that can be used to work with your databases with an application. It's very useful to see, update and test your data. Shell application support all database commands in a similar MongoDB shell syntax.

Shell commands are available in LiteDatabase too. You can execute any command:

using(var db = new LiteDatabase("MyDatabase.db"))
{
    db.Run("db.customer.insert { _id:1, Name: \"John Doe\" }");

    var col = db.GetCollection("customer");
    var john = col.FindById(1);
}

Reference

Shell console commands

The commands here works only in console application LiteDB.Shell.exe:

  • help [full] - Display basic or full commands help
  • open [filename] - Open new database. If not exists, create a new one
  • close - Close current database
  • pretty - Show JSON in pretty format
  • ed - Open notepad.exe with last command to edit
  • run [filename] - Read filename as interpret each line as a new command
  • spool [on|off] - Turn on/off spool of all commands
  • timer - Show a timer on command prompt
  • -- - Comment line - ignored line
  • /[command]/ - Supports multiline command
  • quit - Exit shell application

Collections commands

Syntax: db.<collection>.<command>

  • insert [JsonDoc] - Find a document using query filter syntax

    • db.customer.insert { _id:1, Name: "John Doe", Age: 38 }
    • db.customer.insert { Name: "John Doe" } - Auto create Id as ObjectId
  • find - Find a document using query filter syntax

    • db.customer.find Name = "John Doe"
    • db.customer.find Name LIKE "John" and Age > 30

FileStorage

Database commands

  • begin - Begin a new transaction

  • commit - Commit current transaction

  • rollback - Rollback current transaction

  • shell in database class

  • command references

  • run shell in db.Shell("command")

Clone this wiki locally